Sha256: 1f4310079c401cb11b3f24a0e42ec738f65f213d632b42bcec0fc49ec0b1d186

Contents?: true

Size: 548 Bytes

Versions: 2

Compression:

Stored size: 548 Bytes

Contents

module SearchFlip
  module Model
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def notifies_index(index)
        if respond_to?(:after_commit)
          after_commit { |record| record.destroyed? ? index.delete(record) : index.import(record)}
        else
          after_save { |record| index.import(record) }
          after_touch { |record| index.import(record) } if respond_to?(:after_touch)
          after_destroy { |record| index.delete(record) }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
search_flip-1.1.0 lib/search_flip/model.rb
search_flip-1.0.0 lib/search_flip/model.rb