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_active_record.traits
end

#from_active_recordObject

Returns the actual association establisher class



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

def from_active_record
  @from_active_record
end

#self_to_self?Boolean

Returns:

  • (Boolean)


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

def self_to_self?
  from_active_record == to_active_record
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_active_recordObject



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

def to_active_record
  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