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, #pretty_xml, #relationship_collections, #root_node_name, #success?

Constructor Details

#initialize(response) ⇒ SitesLinkingIn

Returns a new instance of SitesLinkingIn.



8
9
10
11
12
# File 'lib/awis/models/sites_linking_in.rb', line 8

def initialize(response)
  @sites = []

  super(response)
end

Instance Attribute Details

#sitesObject

Returns the value of attribute sites.



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

def sites
  @sites
end

Instance Method Details

#setup_data!(response) ⇒ Object



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

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