Class: Awis::Models::SitesLinkingIn

Inherits:
Base
  • Object
show all
Defined in:
lib/awis/models/sites_linking_in.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#request_id, #response, #status_code

Instance Method Summary collapse

Methods inherited from Base

#action_name, #loading_response, #relationship_collections, #root_node_name, #success?

Constructor Details

#initialize(response) ⇒ SitesLinkingIn

Returns a new instance of SitesLinkingIn.



6
7
8
9
# File 'lib/awis/models/sites_linking_in.rb', line 6

def initialize(response)
  @sites = []
  setup_data! loading_response(response)
end

Instance Attribute Details

#sitesObject

Returns the value of attribute sites.



4
5
6
# File 'lib/awis/models/sites_linking_in.rb', line 4

def sites
  @sites
end

Instance Method Details

#setup_data!(response) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/awis/models/sites_linking_in.rb', line 11

def setup_data!(response)
  sites = []

  response.each_node do |node, path|
    text = node.inner_xml
    text = nil if (text.class == String && text.empty?)

    if node.name == 'aws:RequestId'
      @request_id ||= text
    elsif node.name == 'aws:StatusCode'
      @status_code ||= text
    elsif node.name == 'aws:Title'
      sites << { title: text }
    elsif node.name == 'aws:Url'
      sites << { url: text }
    end
  end

  relationship_collections(@sites, sites, 2, Site)
end