Class: SecurityTrails::Response

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/securitytrails/response.rb

Instance Method Summary collapse

Instance Method Details

#openstruct_to_hash(object, hash = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/securitytrails/response.rb', line 7

def openstruct_to_hash(object, hash = {})
  object.each_pair do |key, value|
    hash[key] = case value
                when OpenStruct then openstruct_to_hash(value)
                when Array then value.map { |v| openstruct_to_hash(v) }
                else value
                end
  end
  hash
end

#to_hObject



18
19
20
# File 'lib/securitytrails/response.rb', line 18

def to_h
  openstruct_to_hash(self)
end