Perform the where(...).first to find_by(...) refactoring.

This refactoring was automated using the command: bundle exec "ruby refactorings/where_dot_first_to_find_by/app.rb"
This commit is contained in:
Louis Rose
2014-05-06 14:41:59 +01:00
parent f1369e4503
commit 1574485443
104 changed files with 204 additions and 213 deletions

View File

@@ -1,14 +1,14 @@
# API to wrap up plugin store rows
class PluginStore
def self.get(plugin_name, key)
if row = PluginStoreRow.where(plugin_name: plugin_name, key: key).first
if row = PluginStoreRow.find_by(plugin_name: plugin_name, key: key)
cast_value(row.type_name, row.value)
end
end
def self.set(plugin_name, key, value)
hash = {plugin_name: plugin_name, key: key}
row = PluginStoreRow.where(hash).first || row = PluginStoreRow.new(hash)
row = PluginStoreRow.find_by(hash) || row = PluginStoreRow.new(hash)
row.type_name = determine_type(value)
# nil are stored as nil