Module: Sunspot::Mongoid

Defined in:
lib/generators/tophold_engine/templates/sunspot_mongoid_patch.rb

Defined Under Namespace

Classes: DataAccessor

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/tophold_engine/templates/sunspot_mongoid_patch.rb', line 11

def self.included(base)
  base.class_eval do
    extend Sunspot::Rails::Searchable::ActsAsMethods
    Sunspot::Adapters::DataAccessor.register(DataAccessor, base)
    Sunspot::Adapters::InstanceAdapter.register(InstanceAdapter, base)

    after_save do
      Sunspot.index! self
    end

    after_delete do
      Sunspot.remove! self
    end

    after_destroy do
      Sunspot.remove! self
    end

  end
end