Module: OM::XML::Properties

Defined in:
lib/om/xml/properties.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ng_xmlObject

Returns the value of attribute ng_xml.



3
4
5
# File 'lib/om/xml/properties.rb', line 3

def ng_xml
  @ng_xml
end

Class Method Details

.included(klass) ⇒ Object

Instance Methods – These methods will be available on instances of classes that include this module



348
349
350
# File 'lib/om/xml/properties.rb', line 348

def self.included(klass)
  klass.extend(ClassMethods)
end

Instance Method Details

#lookup(property_ref, query_opts = {}, opts = {}) ⇒ Object

Applies the property’s corresponding xpath query, returning the result Nokogiri::XML::NodeSet



353
354
355
356
357
358
359
360
361
362
363
# File 'lib/om/xml/properties.rb', line 353

def lookup( property_ref, query_opts={}, opts={} )
  xpath_query = xpath_query_for( property_ref, query_opts, opts )
  
  if xpath_query.nil?
    result = []
  else
    result = ng_xml.xpath(xpath_query, ox_namespaces)
  end
  
  return result
end

#ox_namespacesObject

Returns a hash combining the current documents namespaces (provided by nokogiri) and any namespaces that have been set up by your class definiton. Most importantly, this matches the ‘oxns’ namespace to the namespace you provided in your root property config



368
369
370
# File 'lib/om/xml/properties.rb', line 368

def ox_namespaces
  @ox_namespaces ||= ng_xml.namespaces.merge(self.class.ox_namespaces)
end

#property_info_for(property_ref) ⇒ Object



376
377
378
# File 'lib/om/xml/properties.rb', line 376

def property_info_for(property_ref)
  self.class.property_info_for(property_ref)
end

#xpath_query_for(property_ref, query_opts = {}, opts = {}) ⇒ Object



372
373
374
# File 'lib/om/xml/properties.rb', line 372

def xpath_query_for( property_ref, query_opts={}, opts={} )
  self.class.xpath_query_for( property_ref, query_opts, opts )
end