Refactor Setting (#3302)
* @object is not needed * Remove unneeded dependencies * Do not call private method * Prefer #respond_to_missing? over #respond_to? `#respond_to?` doesn't support `User.settings.method(:method_name)` * Use find_or_initialize_by instead of
This commit is contained in:
parent
2469fd1cdc
commit
08dce5e607
3 changed files with 7 additions and 12 deletions
|
@ -23,7 +23,7 @@ class Setting < RailsSettings::Base
|
|||
def [](key)
|
||||
return super(key) unless rails_initialized?
|
||||
|
||||
val = Rails.cache.fetch(cache_key(key, @object)) do
|
||||
val = Rails.cache.fetch(cache_key(key, nil)) do
|
||||
db_val = object(key)
|
||||
|
||||
if db_val
|
||||
|
@ -50,8 +50,6 @@ class Setting < RailsSettings::Base
|
|||
records
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_settings
|
||||
return {} unless RailsSettings::Default.enabled?
|
||||
RailsSettings::Default.instance
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue