Class: Chewy::Index::Observe::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/chewy/index/observe/callback.rb

Instance Method Summary collapse

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