Class: LatoSettings::Setting
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- LatoSettings::Setting
- Defined in:
- app/models/lato_settings/setting.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
Class Method Summary collapse
-
.get(key, default = nil) ⇒ Object
DEPRECATED METHOD: TO BE REMOVED IN FUTURE VERSIONS.
-
.load_cache ⇒ Object
DEPRECATED METHOD: TO BE REMOVED IN FUTURE VERSIONS.
Instance Method Summary collapse
- #option_max ⇒ Object
- #option_min ⇒ Object
- #option_step ⇒ Object
- #option_values ⇒ Object
- #reload_cache ⇒ Object
-
#value_formatted ⇒ Object
Helpers.
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
3 4 5 |
# File 'app/models/lato_settings/setting.rb', line 3 def actions @actions end |
Class Method Details
.get(key, default = nil) ⇒ Object
DEPRECATED METHOD: TO BE REMOVED IN FUTURE VERSIONS
79 80 81 82 |
# File 'app/models/lato_settings/setting.rb', line 79 def self.get(key, default = nil) Rails.logger.warn "LatoSettings::Setting.get is deprecated. Use LatoSettings.get instead." LatoSettings.get(key, default) end |
.load_cache ⇒ Object
DEPRECATED METHOD: TO BE REMOVED IN FUTURE VERSIONS
85 86 87 88 |
# File 'app/models/lato_settings/setting.rb', line 85 def self.load_cache Rails.logger.warn "LatoSettings::Setting.load_cache is deprecated. Use LatoSettings.reset_cache instead." LatoSettings.reset_cache end |
Instance Method Details
#option_max ⇒ Object
63 64 65 |
# File 'app/models/lato_settings/setting.rb', line 63 def option_max &.dig('max') || nil end |
#option_min ⇒ Object
59 60 61 |
# File 'app/models/lato_settings/setting.rb', line 59 def option_min &.dig('min') || nil end |
#option_step ⇒ Object
67 68 69 |
# File 'app/models/lato_settings/setting.rb', line 67 def option_step &.dig('step') || 1 end |
#option_values ⇒ Object
71 72 73 |
# File 'app/models/lato_settings/setting.rb', line 71 def option_values &.dig('values') || [] end |
#reload_cache ⇒ Object
33 34 35 |
# File 'app/models/lato_settings/setting.rb', line 33 def reload_cache LatoSettings.reset_cache end |
#value_formatted ⇒ Object
Helpers
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/models/lato_settings/setting.rb', line 40 def value_formatted return nil if value.nil? case typology when 'string' value.to_s when 'number' value.to_f when 'date' Date.parse(value) when 'select' option_values.include?(value) ? value : nil when 'integer' value.to_i else value.to_s end end |