Module: Slingshot::Model::Callbacks

Defined in:
lib/slingshot/model/callbacks.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/slingshot/model/callbacks.rb', line 6

def self.included(base)
  if base.respond_to?(:after_save) && base.respond_to?(:after_destroy)
    base.send :after_save,    :update_elastic_search_index
    base.send :after_destroy, :update_elastic_search_index
  end

  if base.respond_to?(:before_destroy) && !base.respond_to?(:destroyed?)
    base.class_eval do
      before_destroy  { @destroyed = true }
      def destroyed?; !!@destroyed; end
    end
  end
end