Module: OM::XML::Document::ClassMethods
- Defined in:
- lib/om/xml/document.rb
Overview
Class Methods – These methods will be available on classes that include this Module
Instance Attribute Summary collapse
-
#template_registry ⇒ Object
Returns the value of attribute template_registry.
-
#terminology ⇒ Object
Returns the value of attribute terminology.
Instance Method Summary collapse
-
#define_template(name, &block) ⇒ Object
Define a new node template with the OM::XML::TemplateRegistry.
-
#ox_namespaces ⇒ Object
Returns any namespaces defined by the Class’ Terminology.
-
#set_terminology(&block) ⇒ Object
Sets the OM::XML::Terminology for the Document Expects &block that will be passed into OM::XML::Terminology::Builder.new.
Instance Attribute Details
#template_registry ⇒ Object
Returns the value of attribute template_registry.
8 9 10 |
# File 'lib/om/xml/document.rb', line 8 def template_registry @template_registry end |
#terminology ⇒ Object
Returns the value of attribute terminology.
8 9 10 |
# File 'lib/om/xml/document.rb', line 8 def terminology @terminology end |
Instance Method Details
#define_template(name, &block) ⇒ Object
Define a new node template with the OM::XML::TemplateRegistry.
-
name
is a Symbol indicating the name of the new template. -
The
block
does the work of creating the new node, and will receive a Nokogiri::XML::Builder and any other args passed to one of the node instantiation methods.
20 21 22 23 |
# File 'lib/om/xml/document.rb', line 20 def define_template name, &block @template_registry ||= OM::XML::TemplateRegistry.new @template_registry.define name, &block end |
#ox_namespaces ⇒ Object
Returns any namespaces defined by the Class’ Terminology
26 27 28 29 30 31 32 |
# File 'lib/om/xml/document.rb', line 26 def ox_namespaces if @terminology.nil? return {} else return @terminology.namespaces end end |
#set_terminology(&block) ⇒ Object
Sets the OM::XML::Terminology for the Document Expects &block that will be passed into OM::XML::Terminology::Builder.new
12 13 14 |
# File 'lib/om/xml/document.rb', line 12 def set_terminology &block @terminology = OM::XML::Terminology::Builder.new( &block ).build end |