class Shamu::Features::Conditions::Proc
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
“`yaml # 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 {Features::Context}.
The custom proj will also have access to the current {Scorpion} if it includes the {Scorpion::Object} mixin.
Public Instance Methods
match?( context )
click to toggle source
(see Condition#match?
)
# File lib/shamu/features/conditions/proc.rb, line 28 def match?( context ) instance( context ).send( proc_method, context, toggle ) end
Private Instance Methods
instance( context )
click to toggle source
# File lib/shamu/features/conditions/proc.rb, line 34 def instance( context ) context.scorpion.fetch( proc_class ) end
proc_class()
click to toggle source
# File lib/shamu/features/conditions/proc.rb, line 38 def proc_class @proc_class ||= proc_config.first.constantize end
proc_config()
click to toggle source
# File lib/shamu/features/conditions/proc.rb, line 46 def proc_config @proc_config ||= config.split( "#" ) end
proc_method()
click to toggle source
# File lib/shamu/features/conditions/proc.rb, line 42 def proc_method proc_config.last end