Class: Settingify::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/settingify/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Group

Returns a new instance of Group.



5
6
7
8
# File 'lib/settingify/group.rb', line 5

def initialize(key)
  @setting_keys = []
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/settingify/group.rb', line 3

def key
  @key
end

#setting_keysObject (readonly)

Returns the value of attribute setting_keys.



3
4
5
# File 'lib/settingify/group.rb', line 3

def setting_keys
  @setting_keys
end

Instance Method Details

#add(setting_key) ⇒ Object



10
11
12
13
14
15
# File 'lib/settingify/group.rb', line 10

def add(setting_key)
  @setting_keys = @setting_keys
    .insert(-1, setting_key.to_sym)
    .uniq
  self
end

#settingsObject



21
22
23
# File 'lib/settingify/group.rb', line 21

def settings
  ::Settingify::Setting.where(key: setting_keys)
end

#titleObject



17
18
19
# File 'lib/settingify/group.rb', line 17

def title
  I18n.t("settingify.groups.#{key}.title", self.key.to_s.humanize)
end