Module: ActiveMongoid::Associations::DocumentRelation::Accessors
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_mongoid/associations/document_relation/accessors.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #build_document(name, object, metadata) ⇒ Object
- #create_document_relation(object, metadata) ⇒ Object
- #set_document_relation(name, object) ⇒ Object
Instance Method Details
#build_document(name, object, metadata) ⇒ Object
7 8 9 10 |
# File 'lib/active_mongoid/associations/document_relation/accessors.rb', line 7 def build_document(name, object, ) relation = create_document_relation(object, ) set_document_relation(name, relation) end |
#create_document_relation(object, metadata) ⇒ Object
16 17 18 19 20 |
# File 'lib/active_mongoid/associations/document_relation/accessors.rb', line 16 def create_document_relation(object, ) type = self.attributes[.inverse_type] target = .builder(self, object).build(type) target ? .relation.new(self, target, ) : nil end |
#set_document_relation(name, object) ⇒ Object
12 13 14 |
# File 'lib/active_mongoid/associations/document_relation/accessors.rb', line 12 def set_document_relation(name, object) instance_variable_set("@#{name}", object) end |