class Falcor::Fabricator
Attributes
factories[RW]
Public Class Methods
create(name, overrides, block)
click to toggle source
# File lib/falcor/fabricator.rb, line 12 def create(name, overrides, block) raise "No factory defined: [#{name}]" unless factories.has_key?(name) factories[name].create(overrides) end
define(name, options={}, &block)
click to toggle source
# File lib/falcor/fabricator.rb, line 8 def define(name, options={}, &block) factories[name] = self.new({ :name => name, :block => block }.merge(options)) end
new(options)
click to toggle source
# File lib/falcor/fabricator.rb, line 30 def initialize(options) @definition = options end
Public Instance Methods
create(overrides)
click to toggle source
# File lib/falcor/fabricator.rb, line 19 def create(overrides) @options = @definition.merge(overrides) @options[:super] = Factory if @options[:super].nil? klass = create_class klass.create_methods(@options[:block]) klass.new(overrides) end
Private Instance Methods
class_name()
click to toggle source
# File lib/falcor/fabricator.rb, line 41 def class_name (@options[:class] || @options[:name]).to_s.camelize end
create_class()
click to toggle source
# File lib/falcor/fabricator.rb, line 34 def create_class Object.send(:remove_const, class_name) rescue nil klass = Object.const_set class_name, Class.new(@options[:super]) klass end