Class: Shamu::Features::Conditions::Proc

Inherits:
Condition
  • Object
show all
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

Methods inherited from Condition

create, #initialize

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.

Parameters:

  • context (Context)

    the feature evaluation context.

Returns:

  • (Boolean)

    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