Commit 7deba5b

mo <mo.khan@gmail.com>
2018-02-26 02:15:23
delegate to to_nokogiri.
1 parent 0e371fc
Changed files (2)
lib/saml/kit/metadata.rb
@@ -214,6 +214,11 @@ module Saml
         @document ||= ::Xml::Kit::Document.new(xml, namespaces: NAMESPACES)
       end
 
+      # @!visibility private
+      def to_nokogiri
+        @nokogiri ||= Nokogiri::XML(xml)
+      end
+
       def at_xpath(xpath)
         document.find_by(xpath)
       end
lib/saml/kit/xsd_validatable.rb
@@ -5,8 +5,7 @@ module Saml
       def matches_xsd?(xsd)
         Dir.chdir(File.dirname(xsd)) do
           xsd = Nokogiri::XML::Schema(IO.read(xsd))
-          document = Nokogiri::XML(to_xml)
-          xsd.validate(document).each do |error|
+          xsd.validate(to_nokogiri).each do |error|
             errors[:base] << error.message
           end
         end