Class: BusinessFlow::Step::Result
- Inherits:
-
Object
- Object
- BusinessFlow::Step::Result
- Defined in:
- lib/business_flow/step.rb
Overview
Represents the result of a step, and allows setting response values on an object, and merging error data into the same object.
Class Method Summary collapse
Instance Method Summary collapse
-
#errors? ⇒ Boolean
:reek:ManualDispatch Checking respond_to? is signficantly faster than eating the NoMethodError when grabbing our error object.
- #executed? ⇒ Boolean
-
#initialize(result, output_map, output_callable) ⇒ Result
constructor
A new instance of Result.
- #merge_into(object) ⇒ Object
- #output ⇒ Object
Constructor Details
#initialize(result, output_map, output_callable) ⇒ Result
Returns a new instance of Result.
38 39 40 41 42 |
# File 'lib/business_flow/step.rb', line 38 def initialize(result, output_map, output_callable) @result = result @output_map = output_map @output_callable = output_callable end |
Class Method Details
.process_output(object, output, output_setter) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/business_flow/step.rb', line 63 def self.process_output(object, output, output_setter) case output_setter when Symbol object.send("#{output_setter}=", output) when Proc object.instance_exec(output, &output_setter) end end |
Instance Method Details
#errors? ⇒ Boolean
:reek:ManualDispatch Checking respond_to? is signficantly faster than eating the NoMethodError when grabbing our error object.
55 56 57 |
# File 'lib/business_flow/step.rb', line 55 def errors? @result.respond_to?(:errors?) ? @result.errors? : false end |
#executed? ⇒ Boolean
49 50 51 |
# File 'lib/business_flow/step.rb', line 49 def executed? true end |
#merge_into(object) ⇒ Object
44 45 46 47 |
# File 'lib/business_flow/step.rb', line 44 def merge_into(object) merge_errors_into(object) merge_outputs_into(object) end |
#output ⇒ Object
59 60 61 |
# File 'lib/business_flow/step.rb', line 59 def output @output_callable.call(@result) end |