Module: Tire::Model::AsyncCallbacks

Defined in:
lib/tire/model/async_callbacks.rb

Constant Summary collapse

ID_CONVERSION =
{
    'Moped::BSON::ObjectId' => :to_s
}

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tire/model/async_callbacks.rb', line 9

def self.included(base)
  # Bind after save or create callback
  if base.respond_to? :after_commit
    base.send :after_commit, :async_tire_save_index

  elsif base.respond_to? :after_save
    base.send :after_save, :async_tire_save_index
  end

  # Bind before destroy callback
  if base.respond_to? :before_destroy
    base.send :before_destroy, :async_tire_delete_index
  end
end