Module: Chewy::Type::Observe

Extended by:
ActiveSupport::Concern
Included in:
Chewy::Type
Defined in:
lib/chewy/type/observe.rb

Defined Under Namespace

Modules: ActiveRecordMethods, ClassMethods, MongoidMethods

Class Method Summary collapse

Class Method Details

.update_proc(type_name, *args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chewy/type/observe.rb', line 6

def self.update_proc(type_name, *args, &block)
  options = args.extract_options!
  method = args.first

  Proc.new do
    backreference = if method && method.to_s == 'self'
      self
    elsif method
      send(method)
    else
      instance_eval(&block)
    end

    Chewy.derive_type(type_name).update_index(backreference, options)
  end
end