Module: ActiveMocker::MockCreator::Associations
- Defined in:
- lib/active_mocker/mock_creator/associations.rb
Instance Method Summary collapse
- #association_collection ⇒ Object
- #belongs_to ⇒ Object
- #has_and_belongs_to_many ⇒ Object
- #has_many ⇒ Object
- #has_one ⇒ Object
- #relation_find(key, value) ⇒ Object
Instance Method Details
#association_collection ⇒ Object
25 26 27 |
# File 'lib/active_mocker/mock_creator/associations.rb', line 25 def association_collection @association_collection ||= schema_scrapper.associations.to_a end |
#belongs_to ⇒ Object
13 14 15 |
# File 'lib/active_mocker/mock_creator/associations.rb', line 13 def belongs_to relation_find(:type, __method__) end |
#has_and_belongs_to_many ⇒ Object
17 18 19 |
# File 'lib/active_mocker/mock_creator/associations.rb', line 17 def has_and_belongs_to_many relation_find(:type, __method__) end |
#has_many ⇒ Object
5 6 7 |
# File 'lib/active_mocker/mock_creator/associations.rb', line 5 def has_many relation_find(:type, __method__) end |
#has_one ⇒ Object
9 10 11 |
# File 'lib/active_mocker/mock_creator/associations.rb', line 9 def has_one relation_find(:type, __method__) end |
#relation_find(key, value) ⇒ Object
21 22 23 |
# File 'lib/active_mocker/mock_creator/associations.rb', line 21 def relation_find(key, value) association_collection.select { |r| r.send(key).to_sym == value } end |