Class: ActiveNode::Associations::SingularAssociation

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

Overview

:nodoc:

Direct Known Subclasses

HasOneAssociation

Instance Attribute Summary

Attributes inherited from Association

#owner, #reflection, #rel_target, #target

Instance Method Summary collapse

Methods inherited from Association

#ids_reader, #ids_writer, #initialize, #klass, #load_ids, #rel, #rels_loader, #rels_reader, #rels_writer, #reset, #save, #validate_type

Constructor Details

This class inherits a constructor from ActiveNode::Associations::Association

Instance Method Details

#id_readerObject



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

def id_reader
  ids_reader.try :first
end

#id_writer(id) ⇒ Object



12
13
14
# File 'lib/active_node/associations/singular_association.rb', line 12

def id_writer(id)
  ids_writer([id].compact)
end

#readerObject



4
5
6
# File 'lib/active_node/associations/singular_association.rb', line 4

def reader
  super.try :first
end

#rel_readerObject



16
17
18
# File 'lib/active_node/associations/singular_association.rb', line 16

def rel_reader
  rels_reader.try :first
end

#rel_writer(rel) ⇒ Object



20
21
22
# File 'lib/active_node/associations/singular_association.rb', line 20

def rel_writer(rel)
  rels_writer([rel].compact)
end

#writer(record) ⇒ Object



24
25
26
# File 'lib/active_node/associations/singular_association.rb', line 24

def writer(record)
  super([record].compact)
end