Module: Traits::Association::Members

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

Instance Method Summary collapse

Instance Method Details

#fromObject



4
5
6
# File 'lib/traits/concerns/association/members.rb', line 4

def from
  @from_class.traits
end

#from_classObject

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

Returns:

  • (Boolean)


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

def self_to_self?
  from_class == to_class
end

#toObject

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_classObject



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

def to_class
  reflection.klass unless polymorphic?
end

#to_hashObject



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