class Nucleon::Config::Collection

Public Class Methods

all() click to toggle source
# File lib/core/config/collection.rb, line 14
def self.all
  @@properties
end
clear() click to toggle source
# File lib/core/config/collection.rb, line 46
def self.clear
  @@lock.synchronize do
    @@properties = {}
  end
end
delete(name) click to toggle source
# File lib/core/config/collection.rb, line 38
def self.delete(name)
  @@lock.synchronize do
    @@properties.delete(name.to_sym)
  end
end
get(name) click to toggle source
# File lib/core/config/collection.rb, line 20
def self.get(name)
  value = nil
  @@lock.synchronize do
    value = @@properties[name.to_sym]
  end
  value
end
save(options = {}) click to toggle source
# File lib/core/config/collection.rb, line 54
def self.save(options = {})
  unless Util::Data.empty?(options[:log_dir])
    @@lock.synchronize do
      log_dir = options[:log_dir]
    
      if options[:config_store]
        unless File.directory?(log_dir)
          FileUtils.mkdir_p(log_dir)
        end
        Util::Disk.write(File.join(log_dir, "properties.json"), Util::Data.to_json(@@properties, true))
        Util::Disk.write(File.join(log_dir, "properties.yaml"), Util::Data.to_yaml(Util::Data.string_map(@@properties)))
      end
    end
  end
end
set(name, value) click to toggle source
# File lib/core/config/collection.rb, line 30
def self.set(name, value)
  @@lock.synchronize do
    @@properties[name.to_sym] = value
  end
end