Class: Formed::Associations::SingularAssociation
- Inherits:
-
Association
- Object
- Association
- Formed::Associations::SingularAssociation
- Defined in:
- lib/formed/associations/singular_association.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Association
#disable_joins, #owner, #reflection, #target
Instance Method Summary collapse
- #build(attributes = nil, &block) ⇒ 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 Association
#extensions, #initialize, #initialize_attributes, #klass, #load_target, #loaded!, #loaded?, #marshal_dump, #marshal_load, #reload, #reset, #reset_negative_cache, #reset_scope, #scope, #set_inverse_instance, #stale_target?
Constructor Details
This class inherits a constructor from Formed::Associations::Association
Instance Method Details
#build(attributes = nil, &block) ⇒ Object
21 22 23 24 25 |
# File 'lib/formed/associations/singular_association.rb', line 21 def build(attributes = nil, &block) record = build_record(attributes, &block) 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
29 30 31 32 |
# File 'lib/formed/associations/singular_association.rb', line 29 def force_reload_reader reload(true) target end |
#reader ⇒ Object
Implements the reader method, e.g. foo.bar for Foo.has_one :bar
7 8 9 10 11 12 13 |
# File 'lib/formed/associations/singular_association.rb', line 7 def reader ensure_klass_exists! reload if !loaded? || stale_target? target end |