Class: DuckRecord::Associations::EmbedsOneAssociation
- Inherits:
-
EmbedsAssociation
- Object
- EmbedsAssociation
- DuckRecord::Associations::EmbedsOneAssociation
- Defined in:
- lib/duck_record/associations/embeds_one_association.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from EmbedsAssociation
Instance Method Summary collapse
- #build(attributes = {}) {|record| ... } ⇒ Object
-
#force_reload_reader ⇒ Object
Implements the reload reader method, e.g.
-
#reader ⇒ Object
Implements the reader method, e.g.
-
#writer(record) ⇒ Object
Implements the writer method, e.g.
Methods inherited from EmbedsAssociation
#initialize, #initialize_attributes, #klass, #loaded?, #marshal_dump, #marshal_load, #reset
Constructor Details
This class inherits a constructor from DuckRecord::Associations::EmbedsAssociation
Instance Method Details
#build(attributes = {}) {|record| ... } ⇒ Object
14 15 16 17 18 19 |
# File 'lib/duck_record/associations/embeds_one_association.rb', line 14 def build(attributes = {}) record = build_record(attributes) yield(record) if block_given? set_new_record(record) record end |
#force_reload_reader ⇒ Object
Implements the reload reader method, e.g. foo.reload_bar for Foo.has_one :bar
23 24 25 26 |
# File 'lib/duck_record/associations/embeds_one_association.rb', line 23 def force_reload_reader klass.uncached { reload } target end |
#reader ⇒ Object
Implements the reader method, e.g. foo.bar for Foo.has_one :bar
5 6 7 |
# File 'lib/duck_record/associations/embeds_one_association.rb', line 5 def reader target end |
#writer(record) ⇒ Object
Implements the writer method, e.g. foo.bar= for Foo.belongs_to :bar
10 11 12 |
# File 'lib/duck_record/associations/embeds_one_association.rb', line 10 def writer(record) replace(record) end |