Class: Shrine::Plugins::Transloadit::TransloaditFile
- Inherits:
-
Object
- Object
- Shrine::Plugins::Transloadit::TransloaditFile
- Defined in:
- lib/shrine/plugins/transloadit.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
-
#transloadit ⇒ Object
readonly
Returns the value of attribute transloadit.
Instance Method Summary collapse
-
#add_step(*args) ⇒ Object
Adds a step to the pipeline, automatically setting :use to the previous step, so that later multiple pipelines can be seamlessly joined into a single assembly.
-
#exported? ⇒ Boolean
Returns true if this TransloaditFile includes an export step.
-
#imported? ⇒ Boolean
Returns true if this TransloaditFile includes an import step.
-
#initialize(transloadit:, steps: []) ⇒ TransloaditFile
constructor
A new instance of TransloaditFile.
-
#name ⇒ Object
The key that Transloadit will use in its processing results for the corresponding processed file.
Constructor Details
#initialize(transloadit:, steps: []) ⇒ TransloaditFile
Returns a new instance of TransloaditFile.
293 294 295 296 |
# File 'lib/shrine/plugins/transloadit.rb', line 293 def initialize(transloadit:, steps: []) @transloadit = transloadit @steps = steps end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
291 292 293 |
# File 'lib/shrine/plugins/transloadit.rb', line 291 def steps @steps end |
#transloadit ⇒ Object (readonly)
Returns the value of attribute transloadit.
291 292 293 |
# File 'lib/shrine/plugins/transloadit.rb', line 291 def transloadit @transloadit end |
Instance Method Details
#add_step(*args) ⇒ Object
Adds a step to the pipeline, automatically setting :use to the previous step, so that later multiple pipelines can be seamlessly joined into a single assembly.
It returns a new TransloaditFile with the step added.
303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/shrine/plugins/transloadit.rb', line 303 def add_step(*args) if args[0].is_a?(::Transloadit::Step) step = args[0] else step = transloadit.step(*args) end unless step.[:use] step.use @steps.last if @steps.any? end TransloaditFile.new(transloadit: transloadit, steps: @steps + [step]) end |
#exported? ⇒ Boolean
Returns true if this TransloaditFile includes an export step.
334 335 336 |
# File 'lib/shrine/plugins/transloadit.rb', line 334 def exported? @steps.any? && @steps.last.robot.end_with?("/store") end |
#imported? ⇒ Boolean
Returns true if this TransloaditFile includes an import step.
329 330 331 |
# File 'lib/shrine/plugins/transloadit.rb', line 329 def imported? @steps.any? && @steps.first.robot.end_with?("/import") end |
#name ⇒ Object
The key that Transloadit will use in its processing results for the corresponding processed file. This equals to the name of the last step, unless the last step is an export step.
320 321 322 323 324 325 326 |
# File 'lib/shrine/plugins/transloadit.rb', line 320 def name if exported? @steps[-2].name else @steps.last.name end end |