Sha256: b53b82df210bbdeaeeed3eca9e0a825efcc1b0c403d6970087d5cad35614e985
Contents?: true
Size: 736 Bytes
Versions: 15
Compression:
Stored size: 736 Bytes
Contents
require 'facet/core/kernel/instance' class OpenStruct # Intercepts some methods to apply to the inner table # rather then be defined as part of the open members. # As with Kernel#instance all other methods are passed # on to the Kernel binding. # # o = OpenStruct.new # o.a = 1 # o.b = 2 # o.instance.each { |k, v| puts "#{k} #{v}" } # # produces # # a 1 # b 2 # # Methods supported: # store, fetch, merge, update, each, key? # def instance Functor.new { |op, *args| case op when :[], :[]=, :store, :fetch, :merge, :update, :each, :key? @table.send(op,*args) else super(op,*args) # send(op,*args) end } end end
Version data entries
15 entries across 15 versions & 1 rubygems