Sha256: 8072d83064cef9330ad38cc55e12c0eebf17c8774e0476fb35216a84cc0fef7b

Contents?: true

Size: 245 Bytes

Versions: 3

Compression:

Stored size: 245 Bytes

Contents

require 'ostruct'
class Hash
  # Turns a hash into a generic object using an OpenStruct.
  #
  #   require 'facet/hash/to_ostruct'
  #
  #   o = { 'a' => 1 }.to_ostruct
  #   o.a  #=> 1
  #
  def to_ostruct
    OpenStruct.new( self )
  end
end 

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/hash/to_ostruct.rb
facets-0.7.1 lib/facet/hash/to_ostruct.rb
facets-0.7.2 lib/facet/hash/to_ostruct.rb