Sha256: db9fccf0954b57e8a57c8a7d6c2d2856c79ad366cbb567c2062edfe484e420aa

Contents?: true

Size: 682 Bytes

Versions: 6

Compression:

Stored size: 682 Bytes

Contents

module Mongoid
  module Elasticsearch
    module Callbacks
      extend ActiveSupport::Concern

      included do
        after_save :update_es_index
        after_destroy :update_es_index
        
        def update_es_index
          es_update
        end
      end

      module ClassMethods
        def without_es_update!( &block )
          skip_callback( :save, :after, :update_es_index )
          skip_callback( :destroy, :after, :update_es_index )
          
          result = yield

          set_callback( :save, :after, :update_es_index )
          set_callback( :destroy, :after, :update_es_index )
          
          result
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-elasticsearch-0.10.0 lib/mongoid/elasticsearch/callbacks.rb
mongoid-elasticsearch-0.9.1 lib/mongoid/elasticsearch/callbacks.rb
mongoid-elasticsearch-0.9.0 lib/mongoid/elasticsearch/callbacks.rb
mongoid-elasticsearch-0.8.3 lib/mongoid/elasticsearch/callbacks.rb
mongoid-elasticsearch-0.8.2 lib/mongoid/elasticsearch/callbacks.rb
mongoid-elasticsearch-0.8.1 lib/mongoid/elasticsearch/callbacks.rb