Skip to content

Instantly share code, notes, and snippets.

@timoschilling
Created September 10, 2015 09:20
Show Gist options
  • Select an option

  • Save timoschilling/edaa32d91966c23fc505 to your computer and use it in GitHub Desktop.

Select an option

Save timoschilling/edaa32d91966c23fc505 to your computer and use it in GitHub Desktop.
Disposible::Twin.fake
class Disposable
class Twin
def self.fake
types = {}
representer_class.representable_attrs[:definitions].each_pair do |key, value|
types[key] = value.instance_variable_get(:@options)[:type]
end
attributes = {}
puts types
types.each_pair do |key, type|
puts key
puts type
puts type.class
attributes[key] = case type.to_s
when "Integer"
Faker::Number.number(10)
when "Time", "DateTime"
Faker::Time.between(2.days.ago, Time.now)
when "String"
Faker::Lorem.word
end
end
attributes
puts attributes
new OpenStruct.new attributes
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment