Module: Objective::Unit
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/objective/unit.rb
Instance Method Summary collapse
-
#build(*args) ⇒ Object
INSTANCE METHODS.
- #outcome(result = nil) ⇒ Object
- #run(*args) ⇒ Object
- #valid? ⇒ Boolean
Instance Method Details
#build(*args) ⇒ Object
INSTANCE METHODS
50 51 52 53 54 55 56 57 58 |
# File 'lib/objective/unit.rb', line 50 def build(*args) filter_result = self.class.root_filter.feed(*args) @raw_inputs = filter_result.coerced @inputs = filter_result.inputs @errors = filter_result.errors @built = true try('validate') if valid? outcome end |
#outcome(result = nil) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/objective/unit.rb', line 70 def outcome(result = nil) Objective::Outcome.new( success: valid?, result: result, errors: @errors, inputs: inputs ) end |
#run(*args) ⇒ Object
60 61 62 63 64 |
# File 'lib/objective/unit.rb', line 60 def run(*args) build(*args) unless built result = valid? ? try('execute') : nil outcome(result) end |
#valid? ⇒ Boolean
66 67 68 |
# File 'lib/objective/unit.rb', line 66 def valid? @errors.nil? end |