Class: ActiveOperation::Pipeline::OperationFactory
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ActiveOperation::Pipeline::OperationFactory
- Defined in:
- lib/active_operation/pipeline.rb
Instance Method Summary collapse
-
#initialize(operation_class, options = {}) ⇒ OperationFactory
constructor
A new instance of OperationFactory.
- #new(context, *input) ⇒ Object
Constructor Details
#initialize(operation_class, options = {}) ⇒ OperationFactory
Returns a new instance of OperationFactory.
4 5 6 7 |
# File 'lib/active_operation/pipeline.rb', line 4 def initialize(operation_class, = {}) super(operation_class) @_options = end |
Instance Method Details
#new(context, *input) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active_operation/pipeline.rb', line 9 def new(context, *input) keyword_input_names = inputs.select(&:keyword?).map(&:name) positional_args = input.shift(inputs.count(&:positional?)) attributes_from_input = input.last.kind_of?(Hash) ? input.pop.slice(*keyword_input_names) : {} attributes_from_input.delete_if { |_, value| value.nil? } attributes_from_pipeline = Array(@_options).each_with_object({}) do |(key, value), result| result[key] = value.kind_of?(Proc) ? context.instance_exec(&value) : value end __getobj__.new *positional_args, attributes_from_input.merge(attributes_from_pipeline) end |