Class: Core::Operation::Callable
- Inherits:
-
Object
- Object
- Core::Operation::Callable
- Defined in:
- lib/core/operation/callable.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
Instance Method Summary collapse
-
#action ⇒ Object
- public
-
Defines an action.
-
#action?(name) ⇒ Boolean
[public].
-
#call(object) ⇒ Object
- public
-
Calls the default operation action with the given arguments.
-
#finalize ⇒ Object
- public
-
Finalizes the operation.
-
#initialize(object) ⇒ Callable
constructor
A new instance of Callable.
- #initialize_copy ⇒ Object
-
#invoke(object, name) ⇒ Object
[public].
-
#relocate(object) ⇒ Object
- public
-
Relocates to another object context.
Constructor Details
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
21 22 23 |
# File 'lib/core/operation/callable.rb', line 21 def actions @actions end |
Instance Method Details
#action ⇒ Object
- public
-
Defines an action.
31 32 33 34 |
# File 'lib/core/operation/callable.rb', line 31 def action(...) @actions << Action.build(...) recompile if compiled? end |
#action?(name) ⇒ Boolean
- public
38 39 40 |
# File 'lib/core/operation/callable.rb', line 38 def action?(name) @actions.any? { |action| action.name == name.to_sym } end |
#call(object) ⇒ Object
- public
-
Calls the default operation action with the given arguments.
44 45 46 |
# File 'lib/core/operation/callable.rb', line 44 def call(object, ...) finalize.call(object, ...) end |
#finalize ⇒ Object
- public
-
Finalizes the operation.
56 57 58 59 60 |
# File 'lib/core/operation/callable.rb', line 56 def finalize compile self end |
#initialize_copy ⇒ Object
16 17 18 19 |
# File 'lib/core/operation/callable.rb', line 16 def initialize_copy(...) @actions = @actions.clone super end |
#invoke(object, name) ⇒ Object
- public
50 51 52 |
# File 'lib/core/operation/callable.rb', line 50 def invoke(object, name, ...) finalize.invoke(object, name, ...) end |
#relocate(object) ⇒ Object
- public
-
Relocates to another object context.
25 26 27 |
# File 'lib/core/operation/callable.rb', line 25 def relocate(object) @object = object end |