Class: Patm::RuleCache
- Inherits:
-
Object
- Object
- Patm::RuleCache
- Defined in:
- lib/patm.rb
Instance Method Summary collapse
-
#initialize(compile = true) ⇒ RuleCache
constructor
A new instance of RuleCache.
- #match(rule_name, obj, _self = nil, &rule) ⇒ Object
Constructor Details
#initialize(compile = true) ⇒ RuleCache
Returns a new instance of RuleCache.
465 466 467 468 |
# File 'lib/patm.rb', line 465 def initialize(compile = true) @compile = compile @rules = {} end |
Instance Method Details
#match(rule_name, obj, _self = nil, &rule) ⇒ Object
469 470 471 |
# File 'lib/patm.rb', line 469 def match(rule_name, obj, _self = nil, &rule) (@rules[rule_name] ||= ::Patm::Rule.new(@compile, &rule)).apply(obj, _self) end |