module Mysqlman::PrivsUtil

Public Instance Methods

all(schema, table, grantable) click to toggle source
# File lib/mysqlman/privs_util.rb, line 5
def all(schema, table, grantable)
  privs = all_privs(schema, table, lebel(schema, table))
  grantable ? privs.push(grant_option(schema, table)) : privs
end

Private Instance Methods

all_privs(schema, table, key) click to toggle source
# File lib/mysqlman/privs_util.rb, line 12
def all_privs(schema, table, key)
  load_privs(key).map do |priv|
    { schema: schema, table: table, type: priv }
  end
end
grant_option(schema = nil, table = nil) click to toggle source
# File lib/mysqlman/privs_util.rb, line 32
def grant_option(schema = nil, table = nil)
  { schema: schema, table: table, type: 'GRANT OPTION' }
end
lebel(schema, table) click to toggle source
# File lib/mysqlman/privs_util.rb, line 18
def lebel(schema, table)
  if schema && table
    'table'
  elsif schema
    'schema'
  else
    'global'
  end
end
load_privs(key) click to toggle source
# File lib/mysqlman/privs_util.rb, line 28
def load_privs(key)
  YAML.load_file(File.join(__dir__, 'all_privileges.yml'))[key].keys
end