Class: Enotas::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/enotas/util.rb

Constant Summary collapse

OBJECT_TYPES =
{
}

Class Method Summary collapse

Class Method Details

.get_object_type(type) ⇒ Object



6
7
8
9
10
# File 'lib/enotas/util.rb', line 6

def self.get_object_type(type)
  object_type = Enotas::EnotasObject
  object_type = OBJECT_TYPES[type] if OBJECT_TYPES[type]
  object_type
end

.symbolize_names(object) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/enotas/util.rb', line 12

def self.symbolize_names(object)
  case object
    when Hash
      new = {}
      object.each do |key, value|
        key = (key.to_sym rescue key) || key
        new[key] = symbolize_names(value)
      end
      new
    when Array
      object.map { |value| symbolize_names(value) }
    else
      object
  end
end