class OM::XML::NamedTermProxy

Attributes

name[RW]
proxy_pointer[RW]
terminology[RW]

Public Class Methods

new(name, proxy_pointer, terminology, opts={}) click to toggle source

Creates a Named Proxy that points to another term in the Terminology. Unlike regular terms, NamedTermProxy requires you to provide a reference to the containing Terminology. This is to ensure that it will always be able to look up the term that it's referencing. @param [Symbol] name of the proxy term @param [Array] proxy_pointer that points to the Term we're proxying @param [OM::XML::Terminology] terminology that this Term is being built for @param [Hash] opts additional Term options

# File lib/om/xml/named_term_proxy.rb, line 14
def initialize(name, proxy_pointer, terminology, opts={})
  opts = {:namespace_prefix=>"oxns", :ancestors=>[], :children=>{}}.merge(opts)
  [:children, :ancestors, :index_as].each do |accessor_name|
    instance_variable_set("@#{accessor_name}", opts.fetch(accessor_name, nil) )     
  end
  @terminology = terminology
  @name = name
  @proxy_pointer = proxy_pointer
end

Public Instance Methods

generate_xpath_queries!() click to toggle source

do nothing – this is to prevent errors when the parent term calls generate_xpath_queries! on its children

# File lib/om/xml/named_term_proxy.rb, line 38
def generate_xpath_queries!
  # do nothing
end
index_as() click to toggle source

Always co-erce :index_as attributes into an Array

# File lib/om/xml/named_term_proxy.rb, line 50
def index_as
  if @index_as
    Array(@index_as)
  else
    self.proxied_term.index_as
  end
end
is_root_term?() click to toggle source

A proxy term can never serve as the root term of a Terminology. Explicitly setting is_root_term? to return false to support proxies that are at the root of the Terminology but aren't the root term.

# File lib/om/xml/named_term_proxy.rb, line 44
def is_root_term?
  return false
end
method_missing(method, *args, &block) click to toggle source

Any unknown method calls will be proxied to the proxied term

# File lib/om/xml/named_term_proxy.rb, line 59
def method_missing method, *args, &block 
  return self.proxied_term.send(method, *args)
end
proxied_term() click to toggle source
# File lib/om/xml/named_term_proxy.rb, line 24
def proxied_term
  if self.parent.nil?
    pt = self.terminology.retrieve_term(*self.proxy_pointer)
  else
    pt = self.parent.retrieve_term(*self.proxy_pointer)
  end
  if pt.nil?
    raise OM::XML::Terminology::BadPointerError, "The #{name} proxy term points to #{proxy_pointer.inspect} but that term doesn't exist."
  else
    return pt
  end
end