Created
September 10, 2015 09:20
-
-
Save timoschilling/edaa32d91966c23fc505 to your computer and use it in GitHub Desktop.
Disposible::Twin.fake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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