Sha256: 6d4c6048ab2d5951c32634e524507244e3f1dd02f6e1f3e525b5743d38a73853

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

# This is the root configatron object, and contains methods which
# operate on the entire configatron hierarchy.
class Configatron::RootStore
  include Singleton

  attr_reader :store

  # Have one global RootStore instance, but allow people to create
  # their own parallel ones if they desire.
  class << self
    public :new
  end

  def initialize
    @locked = false
    reset!
  end

  def method_missing(name, *args, &block)
    store.send(name, *args, &block)
  end

  def reset!
    @store = Configatron::Store.new(self)
  end

  def temp(&block)
    temp_start
    yield
    temp_end
  end

  def temp_start
    @temp = Configatron::DeepClone.deep_clone(@store)
  end

  def temp_end
    @store = @temp
  end

  def locked?
    @locked
  end

  def lock!
    @locked = true
  end

  def unlock!
    @locked = false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
configatron-4.0.0 lib/configatron/root_store.rb