Class: Ansr::OpenStructWithHashAccess

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/ansr/utils.rb

Direct Known Subclasses

NestedOpenStructWithHashAccess

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/ansr/utils.rb', line 10

def [](key)
  send key
end

#[]=(key, value) ⇒ Object



6
7
8
# File 'lib/ansr/utils.rb', line 6

def []=(key, value)
  send "#{key}=", value
end

#merge(other_hash) ⇒ Object



18
19
20
# File 'lib/ansr/utils.rb', line 18

def merge other_hash
  self.class.new to_h.merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
end

#merge!(other_hash) ⇒ Object



22
23
24
# File 'lib/ansr/utils.rb', line 22

def merge! other_hash
  @table.merge!((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
end

#to_hObject



14
15
16
# File 'lib/ansr/utils.rb', line 14

def to_h
  @table
end