lib/pickle/adapter.rb in pickle-0.4.7 vs lib/pickle/adapter.rb in pickle-0.4.8

- old
+ new

@@ -104,18 +104,32 @@ end # factory-girl adapter class FactoryGirl < Adapter def self.factories - (::Factory.factories.values rescue []).map {|factory| new(factory)} + if defined? ::FactoryGirl + factories = [] + ::FactoryGirl.factories.each {|v| factories << new(v)} + factories + else + (::Factory.factories.values rescue []).map {|factory| new(factory)} + end end def initialize(factory) - @klass, @name = factory.build_class, factory.factory_name.to_s + if defined? ::FactoryGirl + @klass, @name = factory.build_class, factory.name.to_s + else + @klass, @name = factory.build_class, factory.factory_name.to_s + end end def create(attrs = {}) - Factory(@name, attrs) + if defined? ::FactoryGirl + ::FactoryGirl.create(@name, attrs) + else + Factory(@name, attrs) + end end end # ORM adapter. If you have no factory adapter, you can use this adapter to # use your orm as 'factory' - ie create objects