Module: Mongoid::Association::Macros
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ActiveSupport::Concern
|
|
Defined in: | lib/mongoid/association/macros.rb |
Overview
This module contains the core macros for defining associations between documents. They can be either embedded or referenced.
Instance Method Summary
-
#associations ⇒ Hash
This is convenience for libraries still on the old API.
DSL Calls
included
[ GitHub ]10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
# File 'lib/mongoid/association/macros.rb', line 10
included do class_attribute :, instance_reader: false class_attribute : class_attribute :relations # A hash that maps aliases to their associations. This hash maps the # associations "in database name" to its "in code" name. This is used when # associations specify the `store_as` option, or on a referenced association. # On a referenced association, this is used to map the foreign key to # the association's name. For example, if we had the following # relationship: # # User has_many Accounts # # User will have an entry in the aliased associations hash: # # account_ids => accounts # # Note that on the belongs_to associations, the mapping from # foreign key => name is not in the aliased_associations hash, but a # mapping from name => foreign key is in the aliased_fields hash. # # @return [ Hash<String, String> ] The aliased associations hash. # # @api private class_attribute :aliased_associations # @return [ Set<String> ] The set of associations that are configured # with :store_as parameter. class_attribute :stored_as_associations self. = false self. = BSON::Document.new self.relations = BSON::Document.new self.aliased_associations = {} self.stored_as_associations = Set.new end
Instance Method Details
#associations ⇒ Hash
This is convenience for libraries still on the old API.
# File 'lib/mongoid/association/macros.rb', line 54
def associations relations end