Class: ClassFactory
- Inherits:
-
Object
- Object
- ClassFactory
- Defined in:
- lib/class_factory/class_factory.rb
Class Attribute Summary collapse
-
.factories ⇒ Object
Returns the value of attribute factories.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.factories ⇒ Object
Returns the value of attribute factories.
5 6 7 |
# File 'lib/class_factory/class_factory.rb', line 5 def factories @factories end |
Class Method Details
.create(name, options, block) ⇒ Object
11 12 13 14 15 |
# File 'lib/class_factory/class_factory.rb', line 11 def create(name, , block) raise "No such class factory defined" if !factories.has_key?(name) .merge!(:migration => block) if block factories[name].create() end |
.define(name, options = {}, &block) ⇒ Object
7 8 9 |
# File 'lib/class_factory/class_factory.rb', line 7 def define(name, = {}, &block) factories[name] = self.new({ :name => name, :migration => block }.merge()) end |
Instance Method Details
#create(override_options) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/class_factory/class_factory.rb', line 18 def create() @options = @definition.merge() @options[:super] = ActiveRecord::Base if @options[:super].nil? create_table if is_active_record?(@options[:super]) klass = create_class klass.class_eval @options[:class_eval] if @options[:class_eval] klass end |