class Clomp::Track
Constants
- VALID_TRACK_TYPES
Attributes
block[R]
error[R]
executed[RW]
left[R]
name[R]
options[R]
right[R]
state[R]
track_from[R]
track_options[R]
Public Class Methods
new(name: (raise Errors::NoTrackProvided), track_options: {}, right: true, track_from: nil, options: Option.new, &block)
click to toggle source
# File lib/clomp/track.rb, line 10 def initialize(name: (raise Errors::NoTrackProvided), track_options: {}, right: true, track_from: nil, options: Option.new, &block) @name = name @track_from = track_from @block = block @track_options = track_options @state = 'pending' @error = nil @right = right @left = !@right @executed = false @options = options end
Public Instance Methods
exec!(object, options)
click to toggle source
Track#exec!
executes the steps defined in the operation class
# File lib/clomp/track.rb, line 42 def exec!(object, options) mark_as_failure! # going to execute! set to failure initially @options = options if object.method(name.to_sym).arity > 1 mark_as_success! if object.public_send(name.to_sym, options, **options) != false else mark_as_success! if object.public_send(name.to_sym, options) != false end @block.(options) if success? && @block self.executed = true self rescue => e @error = e.message self.executed = false mark_as_failure! self end
executed?()
click to toggle source
# File lib/clomp/track.rb, line 23 def executed? @executed == true end
left_track?()
click to toggle source
# File lib/clomp/track.rb, line 33 def left_track? !right_track? end
right_track?()
click to toggle source
# File lib/clomp/track.rb, line 37 def right_track? @right end
type()
click to toggle source
# File lib/clomp/track.rb, line 27 def type @right ? :right_track : :left_track end
Also aliased as: track?