lib/symbiont/executor.rb in symbiont-ruby-0.2.0 vs lib/symbiont/executor.rb in symbiont-ruby-0.3.0
- old
+ new
@@ -30,11 +30,12 @@
# @see Symbiont::Trigger#__evaluate__
#
# @api public
# @since 0.1.0
def evaluate(*required_contexts, context_direction: Trigger::IOK, &closure)
- public_trigger(*required_contexts, context_direction: context_direction, &closure).__evaluate__
+ Isolator.new(default_direction: context_direction, &closure)
+ .evaluate(*required_contexts)
end
# 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.
#
@@ -57,69 +58,14 @@
# @see Symbiont::Trigger#__evaluate__
#
# @api public
# @since 0.1.0
def evaluate_private(*required_contexts, context_direction: Trigger::IOK, &closure)
- private_trigger(*required_contexts, context_direction: context_direction, &closure).__evaluate__
+ Isolator.new(default_direction: context_direction, &closure)
+ .evaluate_private(*required_contexts)
end
- # Factory method that instantiates a public trigger with the desired execution context,
- # the direction of method dispatching and the closure that needs to be performed.
- #
- # @param required_contexts [Array<Object>]
- # A set of objects that should be used as the main context series for method resolving
- # algorithm.
- # @param 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
- # @param closure [Proc]
- # Proc object that will be evaluated in many contexts: initial, outer and kernel.
- # @return [Symbiont::PublicTrigger]
- #
- # @see Symbiont::PublicTrigger
- # @see Symbiont::Trigger
- #
- # @api public
- # @since 0.1.0
- def public_trigger(*required_contexts, context_direction: Trigger::IOK, &closure)
- PublicTrigger.new(*required_contexts, context_direction: context_direction, &closure)
- end
-
- # Factory method that instantiates a private trigger with the desired execution context,
- # the direction of method dispatching and the closure that needs to be performed.
- #
- # @param required_contexts [Array<Object>]
- # A set of objects that should be used as the main context series for method resolving
- # algorithm.
- # @param 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
- # @param closure [Proc]
- # Proc object that will be evaluated in many contexts: initial, outer and kernel.
- # @return [Symbiont::PrivateTrigger]
- #
- # @see Symbiont::PrivateTrigger
- # @see Symbiont::Trigger
- #
- # @api public
- # @since 0.1.0
- def private_trigger(*required_contexts, context_direction: Trigger::IOK, &closure)
- PrivateTrigger.new(*required_contexts, context_direction: context_direction, &closure)
- end
-
# Gets the method object taken from the context that can respond to it.
# Considers only public methods.
#
# @param method_name [Symbol,String] A name of required method.
# @param required_contexts [Array<Object>]
@@ -140,11 +86,12 @@
# @see Symbiont::Trigger#method
#
# @api public
# @since 0.1.0
def public_method(method_name, *required_contexts, context_direction: Trigger::IOK, &closure)
- public_trigger(*required_contexts, context_direction: context_direction, &closure).method(method_name)
+ Isolator.new(default_direction: context_direction, &closure)
+ .public_method(method_name, *required_contexts)
end
# Gets the method object taken from the context that can respond to it.
# Considers private methods and public methods.
#
@@ -167,10 +114,11 @@
# @see Symbiont::Trigger#method
#
# @api public
# @since 0.1.0
def private_method(method_name, *required_contexts, context_direction: Trigger::IOK, &closure)
- private_trigger(*required_contexts, context_direction: context_direction, &closure).method(method_name)
+ Isolator.new(default_direction: context_direction, &closure)
+ .private_method(method_name, *required_contexts)
end
end
end
end