Module: Mongoid::Lookup::Reference::ClassMethods

Defined in:
lib/mongoid_lookup/reference.rb

Instance Method Summary collapse

Instance Method Details

#configure_lookup_reference(options) ⇒ Object

Parameters:

  • options (Array)

Options Hash (options):

  • :map (Hash)


12
13
14
# File 'lib/mongoid_lookup/reference.rb', line 12

def configure_lookup_reference options
  resolve_lookup_field_map(options)
end

#lookup_field_mapHash

Returns map of source fields to reference fields.

Returns:

  • (Hash)

    map of source fields to reference fields



25
26
27
# File 'lib/mongoid_lookup/reference.rb', line 25

def lookup_field_map
  instance_variable_get(:@field_map)
end

#resolve_lookup_field_map(options) ⇒ Object

inherit field map and merge new fields



19
20
21
22
# File 'lib/mongoid_lookup/reference.rb', line 19

def resolve_lookup_field_map options
  map = (superclass.instance_variable_get(:@field_map) or {}).dup.merge((options[:map] or {}))
  instance_variable_set(:@field_map, map)
end