Class: Backyard::Adapter::FactoryGirl

Inherits:
Backyard::Adapter show all
Defined in:
lib/backyard/adapter/factory_girl.rb

Instance Method Summary collapse

Methods inherited from Backyard::Adapter

#generate_model_name

Instance Method Details

#class_for_type(model_type) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
# File 'lib/backyard/adapter/factory_girl.rb', line 3

def class_for_type(model_type)
  factory = ::Factory.factories[model_type.to_sym]
  raise ArgumentError, "no factory for: #{model_type}\ngot: #{::Factory.factories.keys}" unless factory
  factory.build_class
end

#create(model_type, attributes) ⇒ Object



9
10
11
# File 'lib/backyard/adapter/factory_girl.rb', line 9

def create(model_type, attributes)
  Factory(model_type, attributes)
end