Class: OpenStruct

Inherits:
Object show all
Defined in:
lib/backports/2.0.0/stdlib/ostruct.rb

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ Object



2
3
4
# File 'lib/backports/2.0.0/stdlib/ostruct.rb', line 2

def [](name)
  @table[name.to_sym]
end

#[]=(name, value) ⇒ Object



6
7
8
# File 'lib/backports/2.0.0/stdlib/ostruct.rb', line 6

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

#each_pairObject



19
20
21
22
# File 'lib/backports/2.0.0/stdlib/ostruct.rb', line 19

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/backports/2.0.0/stdlib/ostruct.rb', line 10

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

#hashObject



15
16
17
# File 'lib/backports/2.0.0/stdlib/ostruct.rb', line 15

def hash
  @table.hash
end

#to_hObject



24
25
26
# File 'lib/backports/2.0.0/stdlib/ostruct.rb', line 24

def to_h
  @table.dup
end