Module: TypedOperation::Operations::Executable
- Included in:
- Base, ImmutableBase
- Defined in:
- lib/typed_operation/operations/executable.rb
Overview
Defines the execution lifecycle for operations with before/after hooks. Operations must implement #perform to define their core logic.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
: (Module) -> void.
Instance Method Summary collapse
-
#after_execute_operation(retval) ⇒ Object
: (untyped) -> untyped.
-
#before_execute_operation ⇒ Object
: () -> void.
-
#call ⇒ Object
: () -> untyped.
-
#execute_operation ⇒ Object
: () -> untyped.
-
#perform ⇒ Object
: () -> untyped.
-
#to_proc ⇒ Object
: () -> Proc.
Class Method Details
.included(base) ⇒ Object
: (Module) -> void
10 11 12 |
# File 'lib/typed_operation/operations/executable.rb', line 10 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#after_execute_operation(retval) ⇒ Object
: (untyped) -> untyped
45 46 47 |
# File 'lib/typed_operation/operations/executable.rb', line 45 def after_execute_operation(retval) retval end |
#before_execute_operation ⇒ Object
: () -> void
41 42 |
# File 'lib/typed_operation/operations/executable.rb', line 41 def before_execute_operation end |
#call ⇒ Object
: () -> untyped
26 27 28 |
# File 'lib/typed_operation/operations/executable.rb', line 26 def call execute_operation end |
#execute_operation ⇒ Object
: () -> untyped
34 35 36 37 38 |
# File 'lib/typed_operation/operations/executable.rb', line 34 def execute_operation before_execute_operation retval = perform after_execute_operation(retval) end |
#perform ⇒ Object
: () -> untyped
50 51 52 |
# File 'lib/typed_operation/operations/executable.rb', line 50 def perform raise InvalidOperationError, "Operation #{self.class} does not implement #perform" end |
#to_proc ⇒ Object
: () -> Proc
31 |
# File 'lib/typed_operation/operations/executable.rb', line 31 def to_proc = method(:call).to_proc |