Module: Settings::InstanceLevel::InstanceMethods

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

Overview

Set of methods that all instances with instance_settings set will share

Instance Method Summary collapse

Instance Method Details

#settings(&block) ⇒ Object

Access settings at instance level



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/iron/settings/instance_level.rb', line 62

def settings(&block)
  # Ensure we have a value store
  unless @settings_values 
    settings_reset!
  end

  # Set up for use, create a cursor to read/write, and we're good to go
  @settings_values.reload_if_needed
  cursor = Settings::Cursor.new(self.class.settings_instance_root, @settings_values, self)
  DslProxy::exec(cursor, &block) if block
  cursor
end

#settings_reset!Object

Throw out any unsaved changes



80
81
82
83
84
85
86
# File 'lib/iron/settings/instance_level.rb', line 80

def settings_reset!
  # Create our value store
  opts = self.class.settings_instance_options
  @settings_values = opts[:store] == :static ? 
    Settings::StaticStore.new(self.class.settings_instance_root, opts) :
    Settings::DBStore.new(self.class.settings_instance_root, self, opts)
end

#settings_save!Object



75
76
77
# File 'lib/iron/settings/instance_level.rb', line 75

def settings_save!
  @settings_values.save if @settings_values
end