class Settings::Node

Base class for groups and entries - provides our structure

Constants

NODE_SEPARATOR

Used to separate node names in a full key

Attributes

key[RW]

All nodes have these items…

name[RW]

All nodes have these items…

parent[RW]

All nodes have these items…

root[RW]

All nodes have these items…

Public Class Methods

new(parent, name = nil) click to toggle source
# File lib/iron/settings/node.rb, line 12
def initialize(parent, name = nil)
  # Validate name
  unless parent.nil? || name.match(/[a-z0-9_]+/)
    raise ArgumentError.new("Invalid settings key name '#{name}' - may only contain a-z, 0-9 and _ characters")
  end
  
  @parent = parent
  @name = name

  if @parent.nil?
    # We are the root!
    @root = self
    @key = nil
  else
    # Normal node, chain ourselves
    @root = parent.root
    if parent.key.blank?
      @key = name
    else
      @key = [@parent.key, name].join(NODE_SEPARATOR)
    end
  end
end

Public Instance Methods

entry?() click to toggle source
# File lib/iron/settings/node.rb, line 40
def entry?
  false
end
group?() click to toggle source
# File lib/iron/settings/node.rb, line 36
def group?
  false
end