class Mongify::Mongoid::Model::Relation
This class defines a relation for an association on a mongoid model
Constants
- BELONGS_TO
Belongs to relation name
- EMBEDDED_IN
Embedded in relation name
- EMBEDS_MANY
Embeds many relation name
- EMBEDS_ONE
Embeds one relation name
- HAS_AND_BELONGS_TO_MANY
Has and belongs to many relation name
- HAS_MANY
Has many relation name
- HAS_ONE
Has one relation name
- OPTION_KEYS
Valid Option key values currently not used
- SINGULARIZE_RELATIONS
List of fields that need to be singularized
- VALID_RELATIONS
Holds a list of all allowed relations
Attributes
association[RW]
name[RW]
options[RW]
Public Class Methods
new(name, association, options = {})
click to toggle source
# File lib/mongify/mongoid/model/relation.rb, line 47 def initialize(name, association, options = {}) @name, @association, @options = name.to_s, association.to_s, options unless VALID_RELATIONS.include?(@name) raise Mongify::Mongoid::InvalidRelation, "Mongoid does not support the relation #{name} for model associations" end #Singularize association if belongs_to or embedded_in self.association = association.singularize if SINGULARIZE_RELATIONS.include? name end