Module: Objective::Unit
- Defined in:
- lib/objective/unit.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#run(*args) ⇒ Object
INSTANCE METHODS.
- #valid? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/objective/unit.rb', line 5 def self.included(base) base.extend ClassMethods base.class_eval do attr_reader :inputs, :raw_inputs const_set('ALLOW', Objective::ALLOW) const_set('DENY', Objective::DENY) end end |
Instance Method Details
#run(*args) ⇒ Object
INSTANCE METHODS
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/objective/unit.rb', line 44 def run(*args) filter_result = self.class.root_filter.feed(*args) @raw_inputs = filter_result.coerced @inputs = filter_result.inputs @errors = filter_result.errors validate if respond_to?(:validate) && valid? result = valid? && respond_to?(:execute) ? execute : nil Objective::Outcome.new( success: valid?, result: result, errors: @errors, inputs: inputs ) end |
#valid? ⇒ Boolean
60 61 62 |
# File 'lib/objective/unit.rb', line 60 def valid? @errors.nil? end |