Module: Traits::Association::Through
- Included in:
- Traits::Association
- Defined in:
- lib/traits/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
29 30 31 32 33 |
# File 'lib/traits/association/through.rb', line 29 def source_association if through? through.associations[reflection.source_reflection.name] end end |
#source_association_name ⇒ Object
35 36 37 |
# File 'lib/traits/association/through.rb', line 35 def source_association_name source_association.try(:name) end |
#through ⇒ Object
11 12 13 14 15 |
# File 'lib/traits/association/through.rb', line 11 def through if through? reflection.through_reflection.klass.traits end end |
#through? ⇒ Boolean
7 8 9 |
# File 'lib/traits/association/through.rb', line 7 def through? reflection.through_reflection.present? end |
#through_association ⇒ Object
23 24 25 26 27 |
# File 'lib/traits/association/through.rb', line 23 def through_association if through? from.associations[reflection.through_reflection.name] end end |
#through_association_name ⇒ Object
39 40 41 42 43 |
# File 'lib/traits/association/through.rb', line 39 def through_association_name if through? through_association.name end end |
#through_class ⇒ Object
17 18 19 20 21 |
# File 'lib/traits/association/through.rb', line 17 def through_class if through? through.active_record end end |
#through_from_key_name ⇒ Object
57 58 59 60 61 |
# File 'lib/traits/association/through.rb', line 57 def through_from_key_name if through? source_association.from_key_name end end |
#through_table_name ⇒ Object
45 46 47 48 49 |
# File 'lib/traits/association/through.rb', line 45 def through_table_name if through? through_association.to_table_name end end |
#through_to_key_name ⇒ Object
51 52 53 54 55 |
# File 'lib/traits/association/through.rb', line 51 def through_to_key_name if through? through_association.to_key_name end end |
#to_hash ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/traits/association/through.rb', line 63 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 |