Module: Traits::Association::Through
- Included in:
- Traits::Association
- Defined in:
- lib/traits/concerns/association/through.rb
Instance Method Summary collapse
- #source_association ⇒ Object
- #source_association_name ⇒ Object
- #through ⇒ Object
- #through? ⇒ Boolean
- #through_association ⇒ Object
- #through_association_name ⇒ Object
- #through_class ⇒ Object
- #through_from_key_name ⇒ Object
- #through_table_name ⇒ Object
- #through_to_key_name ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#source_association ⇒ Object
26 27 28 29 30 |
# File 'lib/traits/concerns/association/through.rb', line 26 def source_association if through? through.associations[reflection.source_reflection.name] end end |
#source_association_name ⇒ Object
32 33 34 |
# File 'lib/traits/concerns/association/through.rb', line 32 def source_association_name source_association.try(:name) end |
#through ⇒ Object
8 9 10 11 12 |
# File 'lib/traits/concerns/association/through.rb', line 8 def through if through? reflection.through_reflection.klass.traits end end |
#through? ⇒ Boolean
4 5 6 |
# File 'lib/traits/concerns/association/through.rb', line 4 def through? reflection.through_reflection.present? end |
#through_association ⇒ Object
20 21 22 23 24 |
# File 'lib/traits/concerns/association/through.rb', line 20 def through_association if through? from.associations[reflection.through_reflection.name] end end |
#through_association_name ⇒ Object
36 37 38 39 40 |
# File 'lib/traits/concerns/association/through.rb', line 36 def through_association_name if through? through_association.name end end |
#through_class ⇒ Object
14 15 16 17 18 |
# File 'lib/traits/concerns/association/through.rb', line 14 def through_class if through? through.active_record end end |
#through_from_key_name ⇒ Object
54 55 56 57 58 |
# File 'lib/traits/concerns/association/through.rb', line 54 def through_from_key_name if through? source_association.from_key_name end end |
#through_table_name ⇒ Object
42 43 44 45 46 |
# File 'lib/traits/concerns/association/through.rb', line 42 def through_table_name if through? through_association.to_table_name end end |
#through_to_key_name ⇒ Object
48 49 50 51 52 |
# File 'lib/traits/concerns/association/through.rb', line 48 def through_to_key_name if through? through_association.to_key_name end end |
#to_hash ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/traits/concerns/association/through.rb', line 60 def to_hash super.merge!( through: through.try(:name), through_association: through_association_name, source_association: source_association_name, through_table_name: through_table_name, through_to_key_name: through_to_key_name, through_from_key_name: through_from_key_name ) end |