Sha256: 70c50e36966533217953ad1d223b2037a745972c3e563acf4bb956c6b8ab8b96
Contents?: true
Size: 540 Bytes
Versions: 3
Compression:
Stored size: 540 Bytes
Contents
class ApiResource < OpenStruct def to_h hashfied_resource = super hashfied_resource.keys.each do |attr| if self.send(attr).kind_of?(ApiResource) hashfied_resource[attr] = hashfied_resource[attr].to_h end end hashfied_resource end def to_json(*args) jsonfied_resource = to_h jsonfied_resource.keys.each do |attr| if self.send(attr).kind_of?(ApiResource) jsonfied_resource[attr] = jsonfied_resource[attr].to_h end end jsonfied_resource.to_json(args) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
enceladus-0.0.6 | spec/support/api_resource.rb |
enceladus-0.0.5 | spec/support/api_resource.rb |
enceladus-0.0.4 | spec/support/api_resource.rb |