Class: ActiveNode::Associations::SingularAssociation
- Inherits:
-
Association
- Object
- Association
- ActiveNode::Associations::SingularAssociation
show all
- Defined in:
- lib/active_node/associations/singular_association.rb
Overview
Instance Attribute Summary
Attributes inherited from Association
#owner, #reflection, #target
Instance Method Summary
collapse
Methods inherited from Association
#initialize, #klass, #reader, #reset, #save, #writer
Instance Method Details
#id_reader ⇒ Object
16
17
18
|
# File 'lib/active_node/associations/singular_association.rb', line 16
def id_reader
target.try :id
end
|
#id_writer(id) ⇒ Object
20
21
22
|
# File 'lib/active_node/associations/singular_association.rb', line 20
def id_writer(id)
writer(klass.find(id.to_i))
end
|
#ids_reader ⇒ Object
12
13
14
|
# File 'lib/active_node/associations/singular_association.rb', line 12
def ids_reader
[id_reader].compact
end
|
#load_target ⇒ Object
4
5
6
|
# File 'lib/active_node/associations/singular_association.rb', line 4
def load_target
super.try :first
end
|
#target_each {|target| ... } ⇒ Object
8
9
10
|
# File 'lib/active_node/associations/singular_association.rb', line 8
def target_each
yield target
end
|