Module: RecursiveOpenStruct::Ruby19Backport

Included in:
RecursiveOpenStruct
Defined in:
lib/recursive_open_struct/ruby_19_backport.rb

Instance Method Summary collapse

Instance Method Details

#[]=(name, value) ⇒ Object



9
10
11
# File 'lib/recursive_open_struct/ruby_19_backport.rb', line 9

def []=(name, value)
  modifiable[new_ostruct_member(name)] = value
end

#each_pairObject



22
23
24
25
# File 'lib/recursive_open_struct/ruby_19_backport.rb', line 22

def each_pair
  return to_enum(:each_pair) { @table.size } unless block_given?
  @table.each_pair{|p| yield p}
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/recursive_open_struct/ruby_19_backport.rb', line 13

def eql?(other)
  return false unless other.kind_of?(OpenStruct)
  @table.eql?(other.table)
end

#hashObject



18
19
20
# File 'lib/recursive_open_struct/ruby_19_backport.rb', line 18

def hash
  @table.hash
end

#initialize_copy(orig) ⇒ Object

Apply fix if necessary:

https://github.com/ruby/ruby/commit/2d952c6d16ffe06a28bb1007e2cd1410c3db2d58


4
5
6
7
# File 'lib/recursive_open_struct/ruby_19_backport.rb', line 4

def initialize_copy(orig)
  super
  @table.each_key{|key| new_ostruct_member(key)}
end