Sha256: 196ab6d341f49c49bbee60cdd451540920739b6bce1d7e7606745f5365773fc0
Contents?: true
Size: 516 Bytes
Versions: 7
Compression:
Stored size: 516 Bytes
Contents
module HTTParty module CoreExt module HashConversions def to_struct o = OpenStruct.new self.each do |k, v| # if id, we create an accessor so we don't get warning about id deprecation if k.to_s == 'id' o.class.class_eval "attr_accessor :id" o.id = v else o.send("#{k}=", v.is_a?(Hash) ? v.to_struct : v) end end o end end end end Hash.send :include, HTTParty::CoreExt::HashConversions
Version data entries
7 entries across 7 versions & 3 rubygems