Class: Prefered::PreferenceSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/prefered/preference.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePreferenceSettings

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

#groupsObject

Returns the value of attribute groups.



23
24
25
# File 'lib/prefered/preference.rb', line 23

def groups
  @groups
end

#preferencesObject

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, options = {})
  @preferences[name.to_sym] = options
end