Class: ConditionalCounterCache::Reflection::Condition
- Inherits:
-
Object
- Object
- ConditionalCounterCache::Reflection::Condition
- Defined in:
- lib/conditional_counter_cache/reflection.rb
Overview
Utility wrapper of ‘option[:condition]`.
Instance Method Summary collapse
- #call(record) ⇒ Object
-
#initialize(value) ⇒ Condition
constructor
A new instance of Condition.
Constructor Details
#initialize(value) ⇒ Condition
Returns a new instance of Condition.
16 17 18 |
# File 'lib/conditional_counter_cache/reflection.rb', line 16 def initialize(value) @value = value end |
Instance Method Details
#call(record) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/conditional_counter_cache/reflection.rb', line 20 def call(record) case @value when Proc record.instance_exec(&@value) when nil true else record.send(@value) end end |