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

- old
+ new

@@ -130,9 +130,33 @@ Factory(@name, attrs) end end end + # fabrication adapter + class Fabrication < Adapter + def self.factories + if defined? ::Fabrication + ::Fabrication::Support.find_definitions if ::Fabrication::Fabricator.schematics.empty? + ::Fabrication::Fabricator.schematics.collect{|v| new(v)} + end + end + + def initialize(factory) + if defined? ::Fabrication + @klass, @name = factory[1].klass, factory[0].to_s + end + end + + def create(attrs = {}) + if defined? ::Fabrication + ::Fabrication::Fabricator.generate(@name.to_sym, { + :save => true + }, 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 class Orm < Adapter def self.factories model_classes.map{|k| new(k)}