Module: RedHaze::Helpers::Resource::ClassMethods
- Defined in:
- lib/red_haze/helpers/resource.rb
Instance Method Summary collapse
Instance Method Details
#import_from_response(response) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/red_haze/helpers/resource.rb', line 79 def import_from_response(response) if response.is_a? Array response.collect { |i| instance_from_hash(i) } elsif response.is_a? Hash instance_from_hash response end end |
#instance_from_hash(arg) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/red_haze/helpers/resource.rb', line 62 def instance_from_hash(arg) case when arg['kind'] class_name = arg.delete('kind').capitalize eval(class_name).new(arg) when arg['type'] Activity.new arg when arg['collection'] Collection.new arg when arg.values.first['kind'] instance_from_hash arg.values.first else raise arg.inspect end end |