Module: Angus::Remote::Response::Hash

Included in:
Angus::Remote::RemoteResponse, Angus::Remote::Representation
Defined in:
lib/angus/remote/response/hash.rb

Instance Method Summary collapse

Instance Method Details

#elementsObject



7
8
9
# File 'lib/angus/remote/response/hash.rb', line 7

def elements
  @elements ||= {}
end

#to_hashObject

Creates a hash base on the object

The object must have an instance variable @elements that is a hash

that keys => element name, value => element value


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/angus/remote/response/hash.rb', line 15

def to_hash
  hash = {}

  elements.each do |name, value|
    if value.is_a?(Angus::Remote::Response::Hash)
      value.to_hash
    elsif value.is_a?(Array)
      hash[name] = build_hash_from_array(value)
    else
      hash[name] = value
    end
  end
end