lib/xommelier/xml/element/namespace.rb in xommelier-0.1.32 vs lib/xommelier/xml/element/namespace.rb in xommelier-0.1.33
- old
+ new
@@ -1,14 +1,16 @@
# coding: utf-8
+# frozen_string_literal: true
################################################
# © Alexander Semyonov, 2011—2013, MIT License #
# Author: Alexander Semyonov <al@semyonov.us> #
################################################
require 'xommelier/xml/element'
require 'active_support/concern'
+require 'active_support/core_ext/module/delegation'
module Xommelier
module Xml
class Element
module Namespace
@@ -30,24 +32,20 @@
value
end
end
# @return [Nokogiri::XML::Schema] schema associated with element's namespace or module
- def schema
- containing_module.schema
- end
+ delegate :schema, to: :containing_module
# @return [String] path to schema file
- def schema_location
- containing_module.schema_location
- end
+ delegate :schema_location, to: :containing_module
protected
# @return [Module, Class]
def containing_module
- @containing_module ||= ("::#{name.gsub(/::[^:]+$/, '')}").constantize
+ @containing_module ||= "::#{name.gsub(/::[^:]+$/, '')}".constantize
end
# @return [Xommelier::Xml::Namespace]
def find_namespace
(self == containing_module ? Xommelier::Xml : containing_module).xmlns
@@ -74,10 +72,10 @@
document = Nokogiri::XML(ensure_xml_document.to_s)
schema.validate(document).each do |error|
@schema_validation_errors << error
end
else
- raise NoSchemaError.new(self)
+ raise NoSchemaError, self
end
end
end
end
end