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.



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

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

#extend_terminology(&block) ⇒ Object

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



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

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

#ox_namespacesObject

Returns any namespaces defined by the Class’ Terminology



78
79
80
# File 'lib/om/xml/document.rb', line 78

def ox_namespaces
  self.terminology.namespaces
end

#rebuild_terminology!Object



44
45
46
# File 'lib/om/xml/document.rb', line 44

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


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

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



64
65
66
67
# File 'lib/om/xml/document.rb', line 64

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