Sha256: 16a375025966122904af0304f5b2afb07e1cddfdff2ef7f062054d68f50e7a54

Contents?: true

Size: 471 Bytes

Versions: 16

Compression:

Stored size: 471 Bytes

Contents

#http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/150311

require 'ostruct'

class ROpenStruct < OpenStruct
        def method_missing(mid, *args)
                mname = mid.id2name
    len = args.length
    if len == 0
      @table[mname.intern] = ROpenStruct.new
      self.new_ostruct_member(mname)
      @table[mname.intern]
    else
        super
    end
        end
end

test = ROpenStruct.new
test.p = "hello"
test.t.s.p.t.z.y.x = "hi"
test.xyz

p test

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mccloud-0.1.1 lib/mccloud/util/rostruct.rb
mccloud-0.0.28 lib/mccloud/util/rostruct.rb
mccloud-0.0.27 lib/mccloud/util/rostruct.rb
mccloud-0.0.26 lib/mccloud/util/rostruct.rb
mccloud-0.0.25 lib/mccloud/util/rostruct.rb
mccloud-0.0.24 lib/mccloud/util/rostruct.rb
mccloud-0.0.23 lib/mccloud/util/rostruct.rb
mccloud-0.0.22 lib/mccloud/util/rostruct.rb
mccloud-0.0.21 lib/mccloud/util/rostruct.rb
mccloud-0.0.20 lib/mccloud/util/rostruct.rb
mccloud-0.0.19 lib/mccloud/util/rostruct.rb
mccloud-0.0.18 lib/mccloud/util/rostruct.rb
mccloud-0.0.17 lib/mccloud/util/rostruct.rb
mccloud-0.0.16 lib/mccloud/util/rostruct.rb
mccloud-0.0.15 lib/mccloud/util/rostruct.rb
mccloud-0.0.14 lib/mccloud/util/rostruct.rb