Class: Prefered::PreferenceSettings
- Inherits:
-
Object
- Object
- Prefered::PreferenceSettings
- Defined in:
- lib/prefered/preference.rb
Instance Attribute Summary collapse
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#preferences ⇒ Object
Returns the value of attribute preferences.
Class Method Summary collapse
Instance Method Summary collapse
- #group(name, &block) ⇒ Object
-
#initialize ⇒ PreferenceSettings
constructor
A new instance of PreferenceSettings.
- #preference(name, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ PreferenceSettings
Returns a new instance of PreferenceSettings.
19 20 21 22 |
# File 'lib/prefered/preference.rb', line 19 def initialize @preferences = {} @groups = {} end |
Instance Attribute Details
#groups ⇒ Object
Returns the value of attribute groups.
23 24 25 |
# File 'lib/prefered/preference.rb', line 23 def groups @groups end |
#preferences ⇒ Object
Returns the value of attribute preferences.
23 24 25 |
# File 'lib/prefered/preference.rb', line 23 def preferences @preferences end |
Class Method Details
.evaluate(&block) ⇒ Object
12 13 14 15 16 |
# File 'lib/prefered/preference.rb', line 12 def evaluate(&block) settings = self.new settings.instance_eval &block settings end |
Instance Method Details
#group(name, &block) ⇒ Object
29 30 31 |
# File 'lib/prefered/preference.rb', line 29 def group(name, &block) @groups[name.to_sym] = PreferenceSettings.evaluate(&block) end |
#preference(name, options = {}) ⇒ Object
25 26 27 |
# File 'lib/prefered/preference.rb', line 25 def preference(name, = {}) @preferences[name.to_sym] = end |