Class: T2Server::XML::XPathCache

Inherits:
Object
  • Object
show all
Includes:
Singleton, Methods
Defined in:
lib/t2-server/xml/xpath_cache.rb

Instance Method Summary collapse

Methods included from Methods

#get_uris_from_doc, #xml_children, #xml_document, #xml_first_child, #xml_input_fragment, #xml_keypair_cred_fragment, #xml_mkdir_fragment, #xml_node_attribute, #xml_node_content, #xml_node_name, #xml_password_cred_fragment, #xml_permissions_fragment, #xml_trust_fragment, #xml_upload_fragment, #xpath_attr, #xpath_compile, #xpath_find, #xpath_first

Constructor Details

#initializeXPathCache

Returns a new instance of XPathCache.



41
42
43
44
# File 'lib/t2-server/xml/xpath_cache.rb', line 41

def initialize
  @cache = {}
  @xpaths = {}
end

Instance Method Details

#[](key) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/t2-server/xml/xpath_cache.rb', line 46

def [](key)
  return nil unless @xpaths.has_key? key
  return @cache[key] if @cache.has_key? key

  xpath = @xpaths[key]
  @cache[key] = xpath_compile(xpath)
end

#register_xpaths(xpaths) ⇒ Object



54
55
56
# File 'lib/t2-server/xml/xpath_cache.rb', line 54

def register_xpaths(xpaths)
  @xpaths.merge! xpaths
end