Module PageTemplate::NamespaceItem
In: lib/PageTemplate/parser.rb

A Namespace object consists of three things:

parent: A parent object to get a value from if the namespace does not ‘know’ a value.

object: An object is a hash or list that contains the values that this namespace will refer to. It may also be an object, in which case, its methods are treated as a hash, with respond_to? and send()

Cache: A cache ensures that a method on an object will only be called once.

Methods

[]   []=   clear   clear_cache   delete   get   parser   set   true?  

Attributes

object  [RW] 
parent  [RW] 

Public Instance methods

[](val,clean_rescue=true)

Alias for get

[]=(key, value)

Alias for set

Clears the cache

clear_cache()

Alias for clear

Removes an entry from the Namespace

Returns the first value found for key in the nested namespaces. Returns nil if no value is found.

Values are checked for in this order through each level of namespace:

  • level.key
  • level.key()
  • level[key]

If a value is not found in any of the nested namespaces, get() searches for the key in the global namespace.

If val is a dot-separated list of words, then ‘key’ is the first part of it. The remainder of the words are sent to key (and further results) to premit accessing attributes of objects.

parser: most namespace objects won‘t be a parser, but pass this query up to the parser object.

Saves a variable key as the string value in the global namespace.

A convenience method to test whether a variable has a true value. Returns nil if flag is not found in the namespace, or flag has a nil value attached to it.

[Validate]