Module: Cuprum::Processing
- Included in:
- Command
- Defined in:
- lib/cuprum/processing.rb
Overview
Functional implementation for creating a command object. Cuprum::Processing defines a #call method, which performs the implementation defined by #process and returns an instance of Cuprum::Result.
Instance Method Summary collapse
-
#arity ⇒ Integer
Returns a nonnegative integer for commands that take a fixed number of arguments.
-
#call(*arguments, **keywords) { ... } ⇒ Cuprum::Result
Executes the command implementation and returns a Cuprum::Result or compatible object.
-
#process(*arguments, **keywords) { ... } ⇒ Object
The implementation of the command, to be executed when the #call method is called.
Instance Method Details
#arity ⇒ Integer
Returns a nonnegative integer for commands that take a fixed number of arguments. For commands that take a variable number of arguments, returns -n-1, where n is the number of required arguments.
65 66 67 |
# File 'lib/cuprum/processing.rb', line 65 def arity method(:process).arity end |
#call(*arguments, **keywords) { ... } ⇒ Cuprum::Result
90 91 92 93 94 95 96 |
# File 'lib/cuprum/processing.rb', line 90 def call(*args, &block) value = process(*args, &block) return value.to_cuprum_result if value_is_result?(value) build_result(value: value) end |
#process(*arguments, **keywords) { ... } ⇒ Object
Note:
This is a private method.
125 126 127 128 129 |
# File 'lib/cuprum/processing.rb', line 125 def process(*_args) error = Cuprum::Errors::CommandNotImplemented.new(command: self) build_result(error: error) end |