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.
Instance Attribute Summary collapse
- 
  
    
      #output  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute output.
 
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)  ⇒ Result 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Result.
 - #merge_into(object) ⇒ Object
 
Constructor Details
#initialize(result, output_map, output) ⇒ Result
Returns a new instance of Result.
      43 44 45 46 47  | 
    
      # File 'lib/business_flow/step.rb', line 43 def initialize(result, output_map, output) @result = result @output = output @output_map = output_map end  | 
  
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
      41 42 43  | 
    
      # File 'lib/business_flow/step.rb', line 41 def output @output end  | 
  
Class Method Details
.process_output(object, output, output_setter) ⇒ Object
      78 79 80 81 82 83 84 85  | 
    
      # File 'lib/business_flow/step.rb', line 78 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.
      61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76  | 
    
      # File 'lib/business_flow/step.rb', line 61 def errors? if @result.respond_to?(:errors?) @result.errors? # This is here to support ActiveRecord. We don't want to call valid? # because that will run validations and a step may return a partially # constructed model. By instead pulling out the errors instance variable # we'll only merge errors if validations have already been run. elsif @result.class.ancestors.include?(ActiveModel::Validations) && @result.instance_variable_defined?(:@errors) @result.instance_variable_get(:@errors).present? elsif @result.respond_to?(:errors) @result.errors.present? else false end end  | 
  
#executed? ⇒ Boolean
      55 56 57  | 
    
      # File 'lib/business_flow/step.rb', line 55 def executed? true end  | 
  
#merge_into(object) ⇒ Object
      49 50 51 52 53  | 
    
      # File 'lib/business_flow/step.rb', line 49 def merge_into(object) merge_errors_into(object) if mergeable_errors? merge_outputs_into(object) if @output_map output end  |