Class: Configatron::RootStore

Inherits:
BasicObject
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/configatron/root_store.rb

Overview

This is the root configatron object, and contains methods which operate on the entire configatron hierarchy.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRootStore

Returns a new instance of RootStore.



18
19
20
21
# File 'lib/configatron/root_store.rb', line 18

def initialize
  @locked = false
  reset!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



23
24
25
# File 'lib/configatron/root_store.rb', line 23

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

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



10
11
12
# File 'lib/configatron/root_store.rb', line 10

def store
  @store
end

Instance Method Details

#lock!Object



49
50
51
# File 'lib/configatron/root_store.rb', line 49

def lock!
  @locked = true
end

#locked?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/configatron/root_store.rb', line 45

def locked?
  @locked
end

#reset!Object



27
28
29
# File 'lib/configatron/root_store.rb', line 27

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

#temp(&block) ⇒ Object



31
32
33
34
35
# File 'lib/configatron/root_store.rb', line 31

def temp(&block)
  temp_start
  yield
  temp_end
end

#temp_endObject



41
42
43
# File 'lib/configatron/root_store.rb', line 41

def temp_end
  @store = @temp
end

#temp_startObject



37
38
39
# File 'lib/configatron/root_store.rb', line 37

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

#unlock!Object



53
54
55
# File 'lib/configatron/root_store.rb', line 53

def unlock!
  @locked = false
end