Sha256: 756f8bdb20f17cd1c90a64310f2ae4c35a293f0ed9ee3ce62a7665f8b4eb890a
Contents?: true
Size: 702 Bytes
Versions: 1
Compression:
Stored size: 702 Bytes
Contents
require 'ostruct' require 'nano/hash/to_h' require 'nano/ostruct/to_h' class OpenStruct # Insert/update hash data on the fly. # # o = OpenStruct.new # o.ostruct_update { :a => 2 } # o.a #=> 2 # def __update__( other ) hash = other.to_h for k,v in hash @table[k.to_sym] = v end end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCOpenStruct < Test::Unit::TestCase def test_update o = OpenStruct.new( { :a => 1 } ) h = { :b => 2 } assert_nothing_raised { o.__update__( h ) } assert_equal( 2, o.b ) end end =end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-0.9.0 | lib/nano/ostruct/__update__.rb |