Module: XMLable::Mixins::NamespaceDefinitionsStorage

Defined in:
lib/xmlable/mixins/namespace_definitions_storage.rb

Overview

NamespaceDefinitionsStorage module contains the logic to manage with XML

namespaces definitions

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/xmlable/mixins/namespace_definitions_storage.rb', line 8

def self.included(base)
  base.send(:extend, ClassMethods)
end

Instance Method Details

#__define_namespaces(handlers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define XML namespaces

Parameters:



27
28
29
30
31
32
# File 'lib/xmlable/mixins/namespace_definitions_storage.rb', line 27

def __define_namespaces(handlers)
  handlers.each do |h|
    next if __node.namespace_scopes.find { |ns| ns.prefix == h.prefix }
    __node.add_namespace_definition(h.prefix ? h.prefix.to_s : nil, h.href)
  end
end

#__namespace_definitionsXMLable::Handlers::Storage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get namespace definition handlers



52
53
54
# File 'lib/xmlable/mixins/namespace_definitions_storage.rb', line 52

def __namespace_definitions
  @__namespace_definitions ||= self.class.__namespace_definitions.clone
end

#__set_namespace_definition(ns) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set XML namespace

Parameters:

  • ns (Nokogiri::XML::Namespace)


41
42
43
# File 'lib/xmlable/mixins/namespace_definitions_storage.rb', line 41

def __set_namespace_definition(ns)
  __namespace_definitions << ns
end

#initializeObject

See Also:



15
16
17
18
# File 'lib/xmlable/mixins/namespace_definitions_storage.rb', line 15

def initialize(*)
  super
  __define_namespaces(__namespace_definitions)
end