]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/mysql/libraries/mysql.rb
Rubocop cleanups
[chef.git] / cookbooks / mysql / libraries / mysql.rb
index 9ddc238c7525c1b21fc506d8bef14bdcf6e8d544..91eb6f9d1c5527f2c4a36e17505e2ff8ab15a72e 100644 (file)
@@ -87,29 +87,31 @@ class Chef
     end
 
     def users
-      @users ||= query("SELECT * FROM user").each_with_object({}) do |users, user|
+      @users ||= query("SELECT * FROM user").each_with_object({}) do |user, users|
         name = "'#{user[:user]}'@'#{user[:host]}'"
 
-        users[name] = USER_PRIVILEGES.each_with_object({}) do |privileges, privilege|
+        users[name] = USER_PRIVILEGES.each_with_object({}) do |privilege, privileges|
           privileges[privilege] = user["#{privilege}_priv".to_sym] == "Y"
         end
       end
     end
 
     def databases
-      @databases ||= query("SHOW databases").each_with_object({}) do |databases, database|
+      @databases ||= query("SHOW databases").each_with_object({}) do |database, databases|
         databases[database[:database]] = {
           :permissions => {}
         }
       end
 
       query("SELECT * FROM db").each do |record|
-        if database = @databases[record[:db]]
-          user = "'#{record[:user]}'@'#{record[:host]}'"
+        database = @databases[record[:db]]
 
-          database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privileges, privilege|
-            privileges << privilege if record["#{privilege}_priv".to_sym] == "Y"
-          end
+        next unless database
+
+        user = "'#{record[:user]}'@'#{record[:host]}'"
+
+        database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges|
+          privileges << privilege if record["#{privilege}_priv".to_sym] == "Y"
         end
       end