Class: Clomp::Operation
- Inherits:
-
Object
- Object
- Clomp::Operation
- Defined in:
- lib/clomp/operation.rb
Class Attribute Summary collapse
-
.track_builders ⇒ Object
To store and read all the tracks!.
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
- .call(mutable_data = {}, immutable_data = {}) ⇒ Object
-
.failure(track_name, track_options: {}, &block) ⇒ Object
get the track name for the failure case!.
-
.finally(track_name, track_options: {}, &block) ⇒ Object
get the track name for the final step! Only one step will be executed!.
-
.track(track_name, track_options: {}, &block) ⇒ Object
get track name and options!.
Instance Method Summary collapse
- #call(track_builders: [], mutable_data: {}, immutable_data: {}) ⇒ Object
-
#exec_steps! ⇒ Object
Execute all the steps! Execute all the tracks!.
- #executed_steps ⇒ Object
-
#steps ⇒ Object
Name of the steps defined in the operation class.
Class Attribute Details
.track_builders ⇒ Object
To store and read all the tracks!
41 42 43 |
# File 'lib/clomp/operation.rb', line 41 def track_builders @track_builders end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
3 4 5 |
# File 'lib/clomp/operation.rb', line 3 def input @input end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/clomp/operation.rb', line 3 def @options end |
Class Method Details
.call(mutable_data = {}, immutable_data = {}) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/clomp/operation.rb', line 64 def call(mutable_data = {}, immutable_data = {}) self.new.call( track_builders: @track_builders, mutable_data: mutable_data, immutable_data: immutable_data ) end |
.failure(track_name, track_options: {}, &block) ⇒ Object
get the track name for the failure case!
51 52 53 54 55 |
# File 'lib/clomp/operation.rb', line 51 def failure(track_name, track_options: {}, &block) @track_builders ||= [] @track_builders << build_track(track_name, , :failed_track, &block) end |
.finally(track_name, track_options: {}, &block) ⇒ Object
get the track name for the final step! Only one step will be executed!
58 59 60 61 62 |
# File 'lib/clomp/operation.rb', line 58 def finally(track_name, track_options: {}, &block) @track_builders ||= [] @track_builders << build_track(track_name, , :finally, &block) end |
.track(track_name, track_options: {}, &block) ⇒ Object
get track name and options!
44 45 46 47 48 |
# File 'lib/clomp/operation.rb', line 44 def track(track_name, track_options: {}, &block) @track_builders ||= [] @track_builders << build_track(track_name, , :track, &block) end |
Instance Method Details
#call(track_builders: [], mutable_data: {}, immutable_data: {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/clomp/operation.rb', line 5 def call(track_builders: [], mutable_data: {}, immutable_data: {}) @track_builders = track_builders @mutable_data = mutable_data @immutable_data = immutable_data @options ||= {} @options[:mutable_data] = mutable_data @options[:immutable_data] = immutable_data exec_steps! end |
#exec_steps! ⇒ Object
Execute all the steps! Execute all the tracks!
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/clomp/operation.rb', line 17 def exec_steps! @track_builders.each do |track| raise Errors::TrackNotDefined, "Please define track: #{track.name}" unless self.respond_to?(track.name) _track = track.exec!(self, @options) break if _track.failure? end @result = Result.new(@options, @track_builders, self) end |
#executed_steps ⇒ Object
29 30 31 |
# File 'lib/clomp/operation.rb', line 29 def executed_steps @track_builders.collect { |track| track.name if track.success? }.compact end |
#steps ⇒ Object
Name of the steps defined in the operation class
34 35 36 |
# File 'lib/clomp/operation.rb', line 34 def steps @track_builders.collect { |track| track.name } end |