Project

General

Profile

Bug #1219 » ostruct.patch

The patch for lib/ostruct.rb - RobertDober (Robert Dober), 02/27/2009 06:11 AM

View differences:

ostruct.new.rb 2009-02-26 22:02:32.000000000 +0100
@table = @table.dup
end
def freeze
@table.freeze
end
def marshal_dump
@table
end
......
unless self.respond_to?(name)
class << self; self; end.class_eval do
define_method(name) { @table[name] }
define_method(:"#{name}=") { |x| @table[name] = x }
define_method(:"#{name}=") { |x| set_table name, x }
end
end
end
......
if len != 1
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
end
if self.frozen?
raise TypeError, "can't modify frozen #{self.class}", caller(1)
end
mname.chop!
self.new_ostruct_member(mname)
@table[mname.intern] = args[0]
set_table mname.intern, args.first
elsif len == 0
@table[mid]
else
......
attr_reader :table # :nodoc:
protected :table
def set_table key, value # :nodoc:
@table[ key ] = value
rescue RuntimeError => e
raise TypeError, "can't modify frozen #{self.class}", caller(1)
end
private :set_table
#
# Compare this object and +other+ for equality.
#
(1-1/2)