Module: TypedOperation::CallableResolver
- Included in:
- Pipeline::StepWrapper, SmartChain
- Defined in:
- lib/typed_operation/callable_resolver.rb
Overview
Utility module for resolving callable objects (operations, procs, chains) and determining how to invoke them (kwargs vs positional).
Instance Method Summary collapse
-
#extract_operation_class(operation) ⇒ Object
: (_Callable) -> untyped.
-
#uses_kwargs?(operation) ⇒ Boolean
: (_Callable) -> bool.
Instance Method Details
#extract_operation_class(operation) ⇒ Object
: (_Callable) -> untyped
9 10 11 12 13 14 15 16 17 |
# File 'lib/typed_operation/callable_resolver.rb', line 9 def extract_operation_class(operation) case operation when Class then operation when TypedOperation::PartiallyApplied then operation.operation_class when TypedOperation::ChainedOperation then extract_operation_class(operation.instance_variable_get(:@left)) when Proc then nil else operation.class end end |
#uses_kwargs?(operation) ⇒ Boolean
: (_Callable) -> bool
20 21 22 23 24 25 26 27 28 |
# File 'lib/typed_operation/callable_resolver.rb', line 20 def uses_kwargs?(operation) op_class = extract_operation_class(operation) return false unless op_class.respond_to?(:positional_parameters) positional = op_class.positional_parameters keywords = op_class.keyword_parameters keywords.any? && positional.empty? end |