Module: OM::XML::Properties
- Defined in:
- lib/om/xml/properties.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#ng_xml ⇒ Object
Returns the value of attribute ng_xml.
Class Method Summary collapse
-
.included(klass) ⇒ Object
Instance Methods – These methods will be available on instances of classes that include this module.
Instance Method Summary collapse
-
#lookup(property_ref, query_opts = {}, opts = {}) ⇒ Object
Applies the property’s corresponding xpath query, returning the result Nokogiri::XML::NodeSet.
-
#ox_namespaces ⇒ Object
Returns a hash combining the current documents namespaces (provided by nokogiri) and any namespaces that have been set up by your class definiton.
- #property_info_for(property_ref) ⇒ Object
- #xpath_query_for(property_ref, query_opts = {}, opts = {}) ⇒ Object
Instance Attribute Details
#ng_xml ⇒ Object
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
364 365 366 |
# File 'lib/om/xml/properties.rb', line 364 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
369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/om/xml/properties.rb', line 369 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_namespaces ⇒ Object
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
384 385 386 |
# File 'lib/om/xml/properties.rb', line 384 def ox_namespaces @ox_namespaces ||= ng_xml.namespaces.merge(self.class.ox_namespaces) end |
#property_info_for(property_ref) ⇒ Object
392 393 394 |
# File 'lib/om/xml/properties.rb', line 392 def property_info_for(property_ref) self.class.property_info_for(property_ref) end |
#xpath_query_for(property_ref, query_opts = {}, opts = {}) ⇒ Object
388 389 390 |
# File 'lib/om/xml/properties.rb', line 388 def xpath_query_for( property_ref, query_opts={}, opts={} ) self.class.xpath_query_for( property_ref, query_opts, opts ) end |