Module: Settings::ClassLevel::ClassMethods

Defined in:
lib/iron/settings/class_level.rb

Instance Method Summary collapse

Instance Method Details

#class_settings_reset!Object

Reset state to default values only - useful in testing



30
31
32
33
34
# File 'lib/iron/settings/class_level.rb', line 30

def class_settings_reset!
  @settings_values = @settings_class_options[:store] == :static ? 
    Settings::StaticStore.new(@settings_class_root, @settings_class_options) :
    Settings::DbStore.new(@settings_class_root, @settings_class_options)
end

#reload_settingsObject

Force a settings reload (from db or file(s) depending on settings) regardless of need to reload automatically. Useful for testing, but not generally needed in production use



38
39
40
41
# File 'lib/iron/settings/class_level.rb', line 38

def reload_settings
  @settings_values.load
  true
end

#settings(&block) ⇒ Object

Access the class-level settings values for this class, returns a Settings::Cursor to read/write, pointed at the root of the settings definition for this class.

Optionally accepts a block for mass assignment using DSL setters, eg:

Foo.settings do
  some_group.some_entry 'some value'
  some_other_entry 250
end


22
23
24
25
26
27
# File 'lib/iron/settings/class_level.rb', line 22

def settings(&block)
  @settings_values.reload_if_needed
  cursor = Settings::Cursor.new(@settings_class_root, @settings_values)
  DslProxy::exec(cursor, &block) if block
  cursor
end