Class: Ext::Settings::Setting

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/settings.rb

Overview

This is the class that represent one setting. You should not use that directly but access it trough the YourApp.settings method.

default_value is the value that you specified when defining the setting.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, key, default_value, &on_change) ⇒ Setting

Returns a new instance of Setting.



141
142
143
144
145
# File 'lib/ext/settings.rb', line 141

def initialize(klass, key, default_value, &on_change)
  @klass, @key = klass, key
  @on_change = on_change
  @default_value = self.value = default_value
end

Instance Attribute Details

#default_valueObject (readonly)

klass is not used here. It’s for YAML.



140
141
142
# File 'lib/ext/settings.rb', line 140

def default_value
  @default_value
end

#keyObject (readonly)

klass is not used here. It’s for YAML.



140
141
142
# File 'lib/ext/settings.rb', line 140

def key
  @key
end

#klassObject (readonly)

klass is not used here. It’s for YAML.



140
141
142
# File 'lib/ext/settings.rb', line 140

def klass
  @klass
end

#valueObject

klass is not used here. It’s for YAML.



140
141
142
# File 'lib/ext/settings.rb', line 140

def value
  @value
end

Instance Method Details

#on_change(&block) ⇒ Object

Raises:

  • (ArgumentError)


156
157
158
159
# File 'lib/ext/settings.rb', line 156

def on_change(&block)
  raise ArgumentError, "please give a block" unless block_given?
  @on_change = block
end