main
 1# frozen_string_literal: true
 2
 3module Saml
 4  module Kit
 5    class AttributeStatement
 6      include XmlParseable
 7
 8      attr_reader :content
 9
10      def initialize(node)
11        @to_nokogiri = node
12        @content = node.to_s
13      end
14
15      def attributes
16        @attributes ||= search('./saml:Attribute').inject({}) do |memo, item|
17          namespace = Saml::Kit::Document::NAMESPACES
18          values = item.search('./saml:AttributeValue', namespace)
19          memo[item.attribute('Name').value] = values.length == 1 ? values[0].try(:text) : values.map { |x| x.try(:text) }
20          memo
21        end.with_indifferent_access
22      end
23    end
24  end
25end