File: ostruct.rb

package info (click to toggle)
ruby-backports 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,460 kB
  • ctags: 703
  • sloc: ruby: 6,195; makefile: 24
file content (27 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class OpenStruct
  def [](name)
    @table[name.to_sym]
  end unless method_defined? :[]

  def []=(name, value)
    modifiable[new_ostruct_member(name)] = value
  end unless method_defined? :[]=

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

  def hash
    @table.hash
  end unless method_defined? :hash

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

  def to_h
    @table.dup
  end unless method_defined? :to_h
end