Module: Symbiont::Executor

Defined in:
lib/symbiont/executor.rb

Overview

Mediator service object that controls the logic of creating triggers and calling them. Acts as a factory for trigerrs and an execution-mediator for procs.

Since:

  • 0.1.0

Class Method Summary collapse

Class Method Details

.evaluate(*required_contexts, context_direction: Trigger::IOK, &closure) ⇒ Object

Starts execution of a proc object in the context of the passed object with the selected direction of method dispatching. Delegates execution to a public trigger.

Parameters:

  • required_contexts (Array<Object>)

    A set of objects that should be used as the main context series for method resolving algorithm.

  • context_direction (Array<Symbol>)

    An array of symbols that represents the direction of contexts. Possible values:

    • Symbiont::IOK
    • Symbiont::OIK
    • Symbiont::OKI
    • Symbiont::IKO
    • Symbiont::KOI
    • Symbiont::KIO
  • closure (Proc)

    Proc object that will be evaluated in many contexts: initial, outer and kernel.

Returns:

  • void

See Also:

Since:

  • 0.1.0


34
35
36
37
# File 'lib/symbiont/executor.rb', line 34

def evaluate(*required_contexts, context_direction: Trigger::IOK, &closure)
  Isolator.new(default_direction: context_direction, &closure)
          .evaluate(*required_contexts)
end

.evaluate_private(*required_contexts, context_direction: Trigger::IOK, &closure) ⇒ Object

Starts execution of a proc object in the context of the passed object with the selected direction of method dispatching. Delegates execution to a private trigger.

Parameters:

  • required_contexts (Array<Object>)

    A set of objects that should be used as the main context series for method resolving algorithm.

  • context_direction (Array<Symbol>)

    An array of symbols that represents the direction of contexts. Possible values:

    • Symbiont::IOK
    • Symbiont::OIK
    • Symbiont::OKI
    • Symbiont::IKO
    • Symbiont::KOI
    • Symbiont::KIO
  • closure (Proc)

    Proc object that will be evaluated in many contexts: initial, outer and kernel.

Returns:

  • void

See Also:

Since:

  • 0.1.0


62
63
64
65
# File 'lib/symbiont/executor.rb', line 62

def evaluate_private(*required_contexts, context_direction: Trigger::IOK, &closure)
  Isolator.new(default_direction: context_direction, &closure)
          .evaluate_private(*required_contexts)
end

.private_method(method_name, *required_contexts, context_direction: Trigger::IOK, &closure) ⇒ Method

Gets the method object taken from the context that can respond to it. Considers private methods and public methods.

Parameters:

  • method_name (Symbol, String)

    A name of required method.

  • required_contexts (Array<Object>)

    A set of objects that should be used as the main context series for method resolving algorithm. An array of symbols that represents the direction of contexts. Possible values:

    • Symbiont::IOK
    • Symbiont::OIK
    • Symbiont::OKI
    • Symbiont::IKO
    • Symbiont::KOI
    • Symbiont::KIO
  • closure (Proc)

    Proc object that will be used as outer-context for method resolution.

Returns:

  • (Method)

See Also:

Since:

  • 0.1.0


118
119
120
121
# File 'lib/symbiont/executor.rb', line 118

def private_method(method_name, *required_contexts, context_direction: Trigger::IOK, &closure)
  Isolator.new(default_direction: context_direction, &closure)
          .private_method(method_name, *required_contexts)
end

.public_method(method_name, *required_contexts, context_direction: Trigger::IOK, &closure) ⇒ Method

Gets the method object taken from the context that can respond to it. Considers only public methods.

Parameters:

  • method_name (Symbol, String)

    A name of required method.

  • required_contexts (Array<Object>)

    A set of objects that should be used as the main context series for method resolving algorithm. An array of symbols that represents the direction of contexts. Possible values:

    • Symbiont::IOK
    • Symbiont::OIK
    • Symbiont::OKI
    • Symbiont::IKO
    • Symbiont::KOI
    • Symbiont::KIO
  • closure (Proc)

    Proc object that will be used as outer-context for method resolution.

Returns:

  • (Method)

See Also:

Since:

  • 0.1.0


90
91
92
93
# File 'lib/symbiont/executor.rb', line 90

def public_method(method_name, *required_contexts, context_direction: Trigger::IOK, &closure)
  Isolator.new(default_direction: context_direction, &closure)
          .public_method(method_name, *required_contexts)
end