Class: ActiveEntity::Associations::Embeds::SingularAssociation

Inherits:
Association
  • Object
show all
Defined in:
lib/active_entity/associations/embeds/singular_association.rb

Overview

:nodoc:

Direct Known Subclasses

EmbeddedInAssociation, EmbedsOneAssociation

Instance Attribute Summary

Attributes inherited from Association

#owner, #reflection, #target

Instance Method Summary collapse

Methods inherited from Association

#extensions, #initialize, #initialize_attributes, #inversed_from, #klass, #loaded?, #marshal_dump, #marshal_load, #remove_inverse_instance, #set_inverse_instance

Constructor Details

This class inherits a constructor from ActiveEntity::Associations::Embeds::Association

Instance Method Details

#build(attributes = {}, &block) ⇒ Object



17
18
19
20
21
# File 'lib/active_entity/associations/embeds/singular_association.rb', line 17

def build(attributes = {}, &block)
  record = build_record(attributes, &block)
  set_new_record(record)
  record
end

#readerObject

Implements the reader method, e.g. foo.bar for Foo.has_one :bar



8
9
10
# File 'lib/active_entity/associations/embeds/singular_association.rb', line 8

def reader
  target
end

#writer(record) ⇒ Object

Implements the writer method, e.g. foo.bar= for Foo.belongs_to :bar



13
14
15
# File 'lib/active_entity/associations/embeds/singular_association.rb', line 13

def writer(record)
  replace(record)
end