Module: Promiscuous::Publisher::Mongoid::Defer::ClassMethods

Defined in:
lib/promiscuous/publisher/mongoid/defer.rb

Instance Method Summary collapse

Instance Method Details

#setup_class_bindingObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/promiscuous/publisher/mongoid/defer.rb', line 57

def setup_class_binding
  super
  klass.class_eval do
    cattr_accessor :publisher_defer_hooked
    return if self.publisher_defer_hooked
    self.publisher_defer_hooked = true

    # TODO Make sure we are not overriding a field, although VERY unlikly
    field :_psp, :type => Boolean
    field :_psv, :type => Integer
    index({:_psp => 1}, :background => true, :sparse => true)

    Promiscuous::Publisher::Mongoid::Defer.hook_mongoid
    Promiscuous::Publisher::Mongoid::Defer.klasses[self.to_s] = self
    Promiscuous::Publisher::Mongoid::Defer.collections[collection.name] = true
  end if klass
end