Class: ActiveFactory::Define
- Inherits:
-
Object
- Object
- ActiveFactory::Define
- Defined in:
- lib/active_factory.rb,
lib/generators/active_factory/install/templates/define_factories.rb
Overview
the class that should be “extended” to define models
Constant Summary collapse
- @@factories =
{}
Class Method Summary collapse
Class Method Details
.factories_hash ⇒ Object
90 91 92 |
# File 'lib/active_factory.rb', line 90 def self.factories_hash @@factories end |
.factory(name, options = {}, &block) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/active_factory.rb', line 77 def self.factory name, = {}, &block model_class = [:class] if parent_sym = [:parent] parent = @@factories[parent_sym] or raise "undefined parent factory #{parent_sym}" end @@factories[name] = FactoryDSL.new.instance_eval { instance_eval(&block) Factory.new name, parent, model_class, @prefer_associations, @attribute_expressions, @after_build, @before_save } end |