class Nucleon::Config::Options

Public Class Methods

all() click to toggle source
# File lib/core/config/options.rb, line 30
def self.all
  @@options
end
clear(contexts) click to toggle source
# File lib/core/config/options.rb, line 66
def self.clear(contexts)
  unless contexts.is_a?(Array)
    contexts = [ contexts ]
  end
  contexts.each do |name|
    @@options.delete(name.to_sym)
  end
end
contexts(contexts = [], hierarchy = []) click to toggle source
# File lib/core/config/options.rb, line 13
def self.contexts(contexts = [], hierarchy = [])
  contexts = [ 'all', contexts ].flatten
  
  unless hierarchy.is_a?(Array)
    hierarchy = ( ! Util::Data.empty?(hierarchy) ? [ hierarchy ].flatten : [] )
  end
  
  hierarchy.each do |group|  
    group_contexts = Util::Data.prefix(group, contexts)
    contexts       = [ contexts, group_contexts ].flatten
  end
  
  return contexts
end
get(contexts, force = true) click to toggle source
# File lib/core/config/options.rb, line 36
def self.get(contexts, force = true)
  options = {}
  
  unless contexts.is_a?(Array)
    contexts = ( ! Util::Data.empty?(contexts) ? [ contexts ].flatten : [] )
  end
  contexts.each do |name|
    name = name.to_sym
    if @@options.has_key?(name)
      options = Util::Data.merge([ options, @@options[name] ], force)
    end
  end
  return options
end
set(contexts, options, force = true) click to toggle source
# File lib/core/config/options.rb, line 53
def self.set(contexts, options, force = true)
  unless contexts.is_a?(Array)
    contexts = ( ! Util::Data.empty?(contexts) ? [ contexts ].flatten : [] )
  end
  contexts.each do |name|
    name = name.to_sym    
    current_options = ( @@options.has_key?(name) ? @@options[name] : {} )
    @@options[name] = Util::Data.merge([ current_options, Config.symbol_map(options) ], force)
  end  
end