Class: Chewy::Index::Observe::Callback
- Inherits:
-
Object
- Object
- Chewy::Index::Observe::Callback
- Defined in:
- lib/chewy/index/observe/callback.rb
Instance Method Summary collapse
- #call(context) ⇒ Object
-
#initialize(executable, filters = {}) ⇒ Callback
constructor
A new instance of Callback.
Constructor Details
#initialize(executable, filters = {}) ⇒ Callback
Returns a new instance of Callback.
5 6 7 8 9 |
# File 'lib/chewy/index/observe/callback.rb', line 5 def initialize(executable, filters = {}) @executable = executable @if_filter = filters[:if] @unless_filter = filters[:unless] end |
Instance Method Details
#call(context) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/chewy/index/observe/callback.rb', line 11 def call(context) return if !@if_filter.nil? && !eval_filter(@if_filter, context) return if !@unless_filter.nil? && eval_filter(@unless_filter, context) eval_proc(@executable, context) end |