lib/render/generator.rb in render-0.0.5 vs lib/render/generator.rb in render-0.0.6
- old
+ new
@@ -1,10 +1,11 @@
# Generators make fake data in non-live mode.
# They are used for attributes of a specified type, and whose name matches its defined matcher.
require "uuid"
require "render/errors"
+require "date"
module Render
class Generator
@instances = []
@@ -62,7 +63,8 @@
Generator.create!(Float, /.*/, proc { rand(0.1..99).round(2) })
Generator.create!(UUID, /.*/, proc { UUID.generate })
Generator.create!(Time, /.*/, proc { |attribute| time = Time.now; (attribute.type == String) ? time.to_s : time })
Generator.create!(Type::Boolean, /.*/, proc { [true, false].sample })
Generator.create!(Type::Enum, /.*/, proc { |attribute| attribute.enums.sample })
+ Generator.create!(Type::Date, /.*/, proc { Time.now.to_date })
end
end