Class: Temping::ModelFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/temping.rb

Instance Method Summary collapse

Constructor Details

#initialize(model_name, options = {}, &block) ⇒ ModelFactory

Returns a new instance of ModelFactory.



34
35
36
37
38
39
# File 'lib/temping.rb', line 34

def initialize(model_name, options = {}, &block)
  @model_name = model_name
  @options = options
  klass.class_eval(&block) if block_given?
  klass.reset_column_information
end

Instance Method Details

#klassObject



41
42
43
44
45
# File 'lib/temping.rb', line 41

def klass
  @klass ||= Object.const_get(@model_name)
rescue NameError
  @klass = build
end