Class: Shamu::Features::Conditions::Proc
- Includes:
- Scorpion::Object
- Defined in:
- lib/shamu/features/conditions/proc.rb
Overview
Match against a custom method. Due to their dynamic nature, proc conditions are much slower and should be reserved for only a few features.
The proc is specified in the configuration by class and method name like
# features.yml
commerce:
buy_now:
select:
- proc: Commerce::BuyNow#match?
Shamu will instantiate a new instance of the Commerce::BuyNow
class
and invoke the match?
method passing the current Shamu::Features::Context.
The custom proj will also have access to the current Scorpion if it includes the Scorpion::Object mixin.
Instance Method Summary collapse
-
#match?(context) ⇒ Boolean
True if the condition matches the given environment.
Methods inherited from Condition
Constructor Details
This class inherits a constructor from Shamu::Features::Conditions::Condition
Instance Method Details
#match?(context) ⇒ Boolean
Returns true if the condition matches the given environment.
28 29 30 |
# File 'lib/shamu/features/conditions/proc.rb', line 28 def match?( context ) instance( context ).send( proc_method, context, toggle ) end |