Sha256: 5bfde6f09f117d611af4a40dd8b97627094da35f90d521ae4a099d444791edb9
Contents?: true
Size: 1.26 KB
Versions: 10
Compression:
Stored size: 1.26 KB
Contents
require 'xommelier/xml' require 'xommelier/xml/element' require 'active_support/core_ext/array/extract_options' module Xommelier module Xml class Namespace attr_reader :uri, :options, :elements, :attributes alias to_s uri def initialize(uri, options = {}, &block) @uri = uri @options = {} @as = options.delete(:as) self.options = options scoped(&block) if block_given? end def as @as unless default? end def ns Xommelier::Xml::Namespace.registry end def options=(options) options.delete(:elements) { [] }.each do |name| element(name) end options.delete(:attributes) { [] }.each do |name| attribute(name) end @options.merge!(options) end def module options[:module] end def schema self.module.schema end def scoped(&block) instance_exec(&block) end def default? uri.to_s == DEFAULT_NS end def to_hash {as.to_s => uri.to_s} end def attribute_name default? ? 'xmlns' : "xmlns:#{as}" end def inspect %(#{attribute_name}="#{uri}") end end end end
Version data entries
10 entries across 10 versions & 1 rubygems