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

Instance Method Summary collapse

Instance Attribute Details

#template_registryObject

Returns the value of attribute template_registry.



15
16
17
# File 'lib/om/xml/document.rb', line 15

def template_registry
  @template_registry
end

#terminologyObject

Returns the value of attribute terminology.



15
16
17
# File 'lib/om/xml/document.rb', line 15

def terminology
  @terminology
end

#terminology_builderObject

Returns the value of attribute terminology_builder.



15
16
17
# File 'lib/om/xml/document.rb', line 15

def terminology_builder
  @terminology_builder
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.



68
69
70
# File 'lib/om/xml/document.rb', line 68

def define_template name, &block
  self.template_registry.define name, &block
end

#extend_terminology(&block) ⇒ Object

Update the OM::XML::Terminology with additional terms



53
54
55
56
# File 'lib/om/xml/document.rb', line 53

def extend_terminology &block
  self.terminology_builder.extend_terminology(&block)
  rebuild_terminology!
end

#ox_namespacesObject

Returns any namespaces defined by the Class’ Terminology



73
74
75
# File 'lib/om/xml/document.rb', line 73

def ox_namespaces
  self.terminology.namespaces
end

#rebuild_terminology!Object



39
40
41
# File 'lib/om/xml/document.rb', line 39

def rebuild_terminology!
  @terminology = @terminology_builder.build
end

#set_terminology(&block) ⇒ Object

Sets the OM::XML::Terminology for the Document If there already is a termnology for this class, it will be replaced. Expects &block that will be passed into OM::XML::Terminology::Builder.new

See Also:

  • If you want to add terms to an existing terminology


47
48
49
50
# File 'lib/om/xml/document.rb', line 47

def set_terminology &block
  @terminology_builder = OM::XML::Terminology::Builder.new(&block)
  rebuild_terminology!
end

#use_terminology(klass) ⇒ Object

(Explicitly) inherit terminology from upstream classes



59
60
61
62
# File 'lib/om/xml/document.rb', line 59

def use_terminology klass
  self.terminology_builder = klass.terminology_builder.dup
  rebuild_terminology!
end