Class: Saml::Kit::AttributeStatement

Inherits:
Object
  • Object
show all
Includes:
XmlParseable
Defined in:
lib/saml/kit/attribute_statement.rb

Constant Summary

Constants included from XmlParseable

XmlParseable::NAMESPACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlParseable

#present?, #to_h, #to_s, #to_xhtml, #to_xml

Constructor Details

#initialize(node) ⇒ AttributeStatement

Returns a new instance of AttributeStatement.



10
11
12
13
# File 'lib/saml/kit/attribute_statement.rb', line 10

def initialize(node)
  @to_nokogiri = node
  @content = node.to_s
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/saml/kit/attribute_statement.rb', line 8

def content
  @content
end

Instance Method Details

#attributesObject



15
16
17
18
19
20
21
22
# File 'lib/saml/kit/attribute_statement.rb', line 15

def attributes
  @attributes ||= search('./saml:Attribute').inject({}) do |memo, item|
    namespace = Saml::Kit::Document::NAMESPACES
    values = item.search('./saml:AttributeValue', namespace)
    memo[item.attribute('Name').value] = values.length == 1 ? values[0].try(:text) : values.map { |x| x.try(:text) }
    memo
  end.with_indifferent_access
end