Module: ActiveMocker::MockCreator::Associations

Defined in:
lib/active_mocker/mock_creator.rb

Instance Method Summary collapse

Instance Method Details

#association_collectionObject



331
332
333
# File 'lib/active_mocker/mock_creator.rb', line 331

def association_collection
  @association_collection ||= schema_scrapper.associations.to_a
end

#belongs_toObject



319
320
321
# File 'lib/active_mocker/mock_creator.rb', line 319

def belongs_to
  relation_find(:type, __method__)
end

#has_and_belongs_to_manyObject



323
324
325
# File 'lib/active_mocker/mock_creator.rb', line 323

def has_and_belongs_to_many
  relation_find(:type, __method__)
end

#has_manyObject



311
312
313
# File 'lib/active_mocker/mock_creator.rb', line 311

def has_many
  relation_find(:type, __method__)
end

#has_oneObject



315
316
317
# File 'lib/active_mocker/mock_creator.rb', line 315

def has_one
  relation_find(:type, __method__)
end

#relation_find(key, value) ⇒ Object



327
328
329
# File 'lib/active_mocker/mock_creator.rb', line 327

def relation_find(key, value)
  association_collection.select { |r| r.send(key).to_sym == value }
end