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(parameter_source, result, output_map, output_callable) ⇒ Result
constructor
A new instance of Result.
- #merge_into(object) ⇒ Object
- #output ⇒ Object
-
#valid? ⇒ Boolean
:reek:ManualDispatch Checking respond_to? is signficantly faster than eating the NoMethodError when grabbing our error object.
Constructor Details
#initialize(parameter_source, result, output_map, output_callable) ⇒ Result
Returns a new instance of Result.
38 39 40 41 42 43 |
# File 'lib/business_flow/step.rb', line 38 def initialize(parameter_source, result, output_map, output_callable) @parameter_source = parameter_source @result = result @output_map = output_map @output_callable = output_callable end |
Class Method Details
.process_output(object, output, output_setter) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/business_flow/step.rb', line 71 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.
57 58 59 |
# File 'lib/business_flow/step.rb', line 57 def errors? @result.respond_to?(:errors?) ? @result.errors? : false end |
#executed? ⇒ Boolean
51 52 53 |
# File 'lib/business_flow/step.rb', line 51 def executed? true end |
#merge_into(object) ⇒ Object
45 46 47 48 49 |
# File 'lib/business_flow/step.rb', line 45 def merge_into(object) merge_errors_into(object) merge_outputs_into(object) output end |
#output ⇒ Object
67 68 69 |
# File 'lib/business_flow/step.rb', line 67 def output @parameter_source.instance_exec(@result, &@output_callable) end |
#valid? ⇒ Boolean
:reek:ManualDispatch Checking respond_to? is signficantly faster than eating the NoMethodError when grabbing our error object.
63 64 65 |
# File 'lib/business_flow/step.rb', line 63 def valid? @result.respond_to?(:valid?) ? @result.valid? : true end |