Method: SettingAccessors::Accessor#fetch
- Defined in:
- lib/setting_accessors/accessor.rb
#fetch(key, default = nil) ⇒ Object
Tries to fetch a setting value using the provided key and #[]. It will only return the default value if there is
- no temporary setting with the given key AND
- no already persisted setting (see #[])
38 39 40 41 42 |
# File 'lib/setting_accessors/accessor.rb', line 38 def fetch(key, default = nil) result = self[key] return default if result.nil? && !has_key?(key) result end |