Sha256: 568e52648d86ed7b7c38039ed4097a1aaaae2d762d6d790e3d70a0fb24af0b0f

Contents?: true

Size: 426 Bytes

Versions: 4

Compression:

Stored size: 426 Bytes

Contents

module Indexes
  module Concern
    extend ActiveSupport::Concern

    included do
      after_commit :index, on: :create
      after_commit :reindex, on: :update
      after_commit :unindex, on: :destroy
    end

    %i(index reindex unindex).each do |name|
      define_method name do
        self.class.index.send name, self
      end
    end

    module ClassMethods

      delegate :search, to: :index

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
indexes-4.0.0.2 lib/indexes/concern.rb
indexes-4.0.0.1 lib/indexes/concern.rb
indexes-4.0.0.0 lib/indexes/concern.rb
indexes-0.0.1 lib/indexes/concern.rb