lib/temping.rb in temping-1.1.0 vs lib/temping.rb in temping-1.2.0
- old
+ new
@@ -7,15 +7,13 @@
ActiveRecord::Base.configurations['temping'] = { :adapter => 'sqlite3', :database => ':memory:' }
ActiveRecord::Base.establish_connection 'temping' unless ActiveRecord::Base.connected?
end
def create_model(model_name, &block)
- if eval("defined?(#{model_name.to_s.classify})")
- raise ModelAlreadyDefined, "Constant #{model_name.to_s.classify} is already defined"
+ unless eval("defined?(#{model_name.to_s.classify})")
+ factory = ModelFactory.new(model_name, &block)
+ factory.klass
end
-
- factory = ModelFactory.new(model_name, &block)
- factory.klass
end
class ModelFactory
attr_accessor :klass
\ No newline at end of file