Module: ActiveMocker::MockCreator::Associations

Defined in:
lib/active_mocker/mock_creator.rb

Instance Method Summary collapse

Instance Method Details

#association_collectionObject



275
276
277
# File 'lib/active_mocker/mock_creator.rb', line 275

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

#belongs_toObject



263
264
265
# File 'lib/active_mocker/mock_creator.rb', line 263

def belongs_to
  relation_find(:type, __method__)
end

#has_and_belongs_to_manyObject



267
268
269
# File 'lib/active_mocker/mock_creator.rb', line 267

def has_and_belongs_to_many
  relation_find(:type, __method__)
end

#has_manyObject



255
256
257
# File 'lib/active_mocker/mock_creator.rb', line 255

def has_many
  relation_find(:type, __method__)
end

#has_oneObject



259
260
261
# File 'lib/active_mocker/mock_creator.rb', line 259

def has_one
  relation_find(:type, __method__)
end

#relation_find(key, value) ⇒ Object



271
272
273
# File 'lib/active_mocker/mock_creator.rb', line 271

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