Module: Settis::Container
- Defined in:
- lib/settis/container.rb
Instance Method Summary collapse
- #namespace(value = nil) ⇒ Object
- #redis ⇒ Object
-
#setting(name, type, options = {}) ⇒ Object
Defines a new setting.
Instance Method Details
#namespace(value) ⇒ Object #namespace ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/settis/container.rb', line 29 def namespace(value = nil) if value.nil? @namespace ||= 'settings' else @namespace = value end end |
#redis ⇒ Object
20 21 22 |
# File 'lib/settis/container.rb', line 20 def redis @redis ||= Redis::Namespace.new(namespace, :redis => Settis.redis) end |
#setting(name, type, options = {}) ⇒ Object
Defines a new setting.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/settis/container.rb', line 43 def setting(name, type, = {}) @settings ||= {} name = name.to_s raise ArgumentError, "The setting '#{name}' already exists." if @settings.key?(name) serializer = Serializer.for(type) raise ArgumentError, "Unknown setting type '#{type}'." if serializer.nil? @settings[name] = ScalarSetting.new(self, name, serializer.new(type), ) end |