Module: Traits::Association::Members

Included in:
Traits::Association
Defined in:
lib/traits/association/members.rb

Instance Method Summary collapse

Instance Method Details

#fromObject



7
8
9
# File 'lib/traits/association/members.rb', line 7

def from
  @from_class.traits
end

#from_classObject

Returns the actual association establisher class



12
13
14
# File 'lib/traits/association/members.rb', line 12

def from_class
  @from_class
end

#self_to_self?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/traits/association/members.rb', line 25

def self_to_self?
  from_class == to_class
end

#toObject

Returns the actual associated class



17
18
19
# File 'lib/traits/association/members.rb', line 17

def to
  reflection.klass.traits unless polymorphic?
end

#to_classObject



21
22
23
# File 'lib/traits/association/members.rb', line 21

def to_class
  reflection.klass unless polymorphic?
end

#to_hashObject



29
30
31
32
33
34
35
# File 'lib/traits/association/members.rb', line 29

def to_hash
  super.merge!(
    from:         from.name,
    to:           to.try(:name),
    self_to_self: self_to_self?
  )
end