Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/conjoin/recursive_ostruct.rb

Direct Known Subclasses

HashIndifferent

Instance Method Summary collapse

Instance Method Details

#to_ostruct(options = {}) ⇒ Object

options:

:exclude => [keys] - keys need to be symbols


7
8
9
# File 'lib/conjoin/recursive_ostruct.rb', line 7

def to_ostruct(options = {})
  convert_to_ostruct_recursive(self, options)
end

#with_sym_keysObject



11
12
13
14
# File 'lib/conjoin/recursive_ostruct.rb', line 11

def with_sym_keys
  # self.inject({}) { |memo, (k,v)| memo[k.to_sym] = v; memo  }
  self.each_with_object({}) { |(k,v), memo| memo[k.to_sym] = v }
end