Class: Settingify::Group
- Inherits:
-
Object
- Object
- Settingify::Group
- Defined in:
- lib/settingify/group.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#setting_keys ⇒ Object
readonly
Returns the value of attribute setting_keys.
Instance Method Summary collapse
- #add(setting_key) ⇒ Object
-
#initialize(key) ⇒ Group
constructor
A new instance of Group.
- #settings ⇒ Object
- #title ⇒ Object
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/settingify/group.rb', line 3 def key @key end |
#setting_keys ⇒ Object (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 |
#settings ⇒ Object
21 22 23 |
# File 'lib/settingify/group.rb', line 21 def settings ::Settingify::Setting.where(key: setting_keys) end |
#title ⇒ Object
17 18 19 |
# File 'lib/settingify/group.rb', line 17 def title I18n.t("settingify.groups.#{key}.title", self.key.to_s.humanize) end |