Module: Traits::Association::Members
- Included in:
- Traits::Association
- Defined in:
- lib/traits/concerns/association/members.rb
Instance Method Summary collapse
- #from ⇒ Object
-
#from_class ⇒ Object
Returns the actual association establisher class.
- #self_to_self? ⇒ Boolean
-
#to ⇒ Object
Returns the actual associated class.
- #to_class ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#from ⇒ Object
4 5 6 |
# File 'lib/traits/concerns/association/members.rb', line 4 def from @from_class.traits end |
#from_class ⇒ Object
Returns the actual association establisher class
9 10 11 |
# File 'lib/traits/concerns/association/members.rb', line 9 def from_class @from_class end |
#self_to_self? ⇒ Boolean
22 23 24 |
# File 'lib/traits/concerns/association/members.rb', line 22 def self_to_self? from_class == to_class end |
#to ⇒ Object
Returns the actual associated class
14 15 16 |
# File 'lib/traits/concerns/association/members.rb', line 14 def to reflection.klass.traits unless polymorphic? end |
#to_class ⇒ Object
18 19 20 |
# File 'lib/traits/concerns/association/members.rb', line 18 def to_class reflection.klass unless polymorphic? end |
#to_hash ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/traits/concerns/association/members.rb', line 26 def to_hash super.merge!( from: from.name, to: to.try(:name), self_to_self: self_to_self? ) end |