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

Instance Method Summary collapse

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_operationObject

: () -> void



41
42
# File 'lib/typed_operation/operations/executable.rb', line 41

def before_execute_operation
end

#callObject

: () -> untyped



26
27
28
# File 'lib/typed_operation/operations/executable.rb', line 26

def call
  execute_operation
end

#execute_operationObject

: () -> 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

#performObject

: () -> 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_procObject

: () -> Proc



31
# File 'lib/typed_operation/operations/executable.rb', line 31

def to_proc = method(:call).to_proc