Sha256: 24fa2387784a3f1b8f55c7f0c68ee2fd06e5a6ff4c7fbbe787cd419e7cb3379b
Contents?: true
Size: 325 Bytes
Versions: 4
Compression:
Stored size: 325 Bytes
Contents
class Hash def to_ostruct(klass = OpenStruct, cch = {}) cch[self] = klass.new each do |key,value| raise "Invalid key: #{ key }" unless key =~ /[a-z_][a-zA-Z0-9_]*/ cch[self].__send__ "#{ key }=", value.is_a?(Hash) ? cch[value] || value.send(__method__,klass,cch) : value end cch[self] end end
Version data entries
4 entries across 4 versions & 2 rubygems