Module: AbRules
- Defined in:
- lib/ab_rules.rb
Defined Under Namespace
Classes: Rule
Class Method Summary collapse
- .rule(content, &block) ⇒ Object
- .split_by_id(id, *alternatives) ⇒ Object
- .split_by_rule(subjects = {}, *rules) ⇒ Object
Class Method Details
.rule(content, &block) ⇒ Object
19 20 21 |
# File 'lib/ab_rules.rb', line 19 def self.rule(content, &block) Rule.new(content, &block) end |
.split_by_id(id, *alternatives) ⇒ Object
23 24 25 26 |
# File 'lib/ab_rules.rb', line 23 def self.split_by_id(id, *alternatives) content = alternatives.flatten[id % alternatives.size] block_given? ? yield(content) : content end |
.split_by_rule(subjects = {}, *rules) ⇒ Object
28 29 30 31 |
# File 'lib/ab_rules.rb', line 28 def self.split_by_rule(subjects = {}, *rules) content = rules.flatten.find { |r| r.match?(subjects) }.apply block_given? ? yield(content) : content end |