Module: Mongoid::Kraken::Autoload::ClassMethods

Defined in:
lib/mongoid/kraken/autoload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#kraken_autoload_keyObject

Returns the value of attribute kraken_autoload_key.



16
17
18
# File 'lib/mongoid/kraken/autoload.rb', line 16

def kraken_autoload_key
  @kraken_autoload_key
end

Instance Method Details

#inherited(subclass) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/mongoid/kraken/autoload.rb', line 18

def inherited(subclass)
  super
  subclass_fields = fields.dup
  kraken_id_field = subclass_fields.delete(kraken_autoload_key)
  subclass_fields[kraken_autoload_key] = Mongoid::Field.new(
      kraken_autoload_key,
      :default => kraken_autoload_default(:name => "#{subclass.name}")
    )
  subclass.fields = subclass_fields
end

#kraken_autoload_config(*args) ⇒ Object



29
30
31
# File 'lib/mongoid/kraken/autoload.rb', line 29

def kraken_autoload_config(*args)
  fields[kraken_autoload_key].instance_variable_set('@default', kraken_autoload_default(*args))
end