Commit 80cceb9

mo <mo@mokhan.ca>
2018-03-17 01:20:17
extract attribute statement class.
1 parent 83eb457
Changed files (2)
lib/saml/kit/assertion.rb
@@ -1,5 +1,7 @@
 # frozen_string_literal: true
 
+require 'saml/kit/attribute_statement'
+
 module Saml
   module Kit
     # This class validates the Assertion
@@ -60,13 +62,8 @@ module Saml
       end
 
       def attributes
-        xpath = './saml:AttributeStatement/saml:Attribute'
-        @attributes ||= search(xpath).inject({}) do |memo, item|
-          namespace = Saml::Kit::Document::NAMESPACES
-          attribute = item.at_xpath('./saml:AttributeValue', namespace)
-          memo[item.attribute('Name').value] = attribute.try(:text)
-          memo
-        end.with_indifferent_access
+        xpath = './saml:AttributeStatement'
+        AttributeStatement.new(search(xpath)).attributes
       end
 
       def started_at
lib/saml/kit/attribute_statement.rb
@@ -0,0 +1,24 @@
+
+module Saml
+  module Kit
+    class AttributeStatement
+      include XmlParseable
+
+      attr_reader :content
+
+      def initialize(node)
+        @to_nokogiri = node
+        @content = node.to_s
+      end
+
+      def attributes
+        @attributes ||= search('./saml:Attribute').inject({}) do |memo, item|
+          namespace = Saml::Kit::Document::NAMESPACES
+          attribute = item.at_xpath('./saml:AttributeValue', namespace)
+          memo[item.attribute('Name').value] = attribute.try(:text)
+          memo
+        end.with_indifferent_access
+      end
+    end
+  end
+end