Class: Shamu::Features::Conditions::Percentage
- Defined in:
- lib/shamu/features/conditions/percentage.rb
Overview
Match against a limited percentage of total users.
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.
11 12 13 14 15 16 17 18 |
# File 'lib/shamu/features/conditions/percentage.rb', line 11 def match?( context ) if context.user_id ( user_id_hash( context.user_id ) ^ toggle_crc ) % 100 < percentage else context.sticky! Random.rand( 100 ) < percentage end end |