Class: Anvil::Mysql::UserCreator

Inherits:
Struct
  • Object
show all
Defined in:
lib/anvil/mysql/user_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#db_passwordObject

Returns the value of attribute db_password

Returns:

  • (Object)

    the current value of db_password



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def db_password
  @db_password
end

#db_userObject

Returns the value of attribute db_user

Returns:

  • (Object)

    the current value of db_user



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def db_user
  @db_user
end

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def host
  @host
end

#mysql_hostObject

Returns the value of attribute mysql_host

Returns:

  • (Object)

    the current value of mysql_host



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def mysql_host
  @mysql_host
end

#mysql_passwordObject

Returns the value of attribute mysql_password

Returns:

  • (Object)

    the current value of mysql_password



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def mysql_password
  @mysql_password
end

#mysql_portObject

Returns the value of attribute mysql_port

Returns:

  • (Object)

    the current value of mysql_port



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def mysql_port
  @mysql_port
end

#mysql_userObject

Returns the value of attribute mysql_user

Returns:

  • (Object)

    the current value of mysql_user



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def mysql_user
  @mysql_user
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



6
7
8
# File 'lib/anvil/mysql/user_creator.rb', line 6

def user
  @user
end

Instance Method Details

#callObject



7
8
9
# File 'lib/anvil/mysql/user_creator.rb', line 7

def call
  ScriptRunner.new(script, user, host, logger).call
end

#db_scriptObject



11
12
13
# File 'lib/anvil/mysql/user_creator.rb', line 11

def db_script
  "CREATE USER '#{db_user}'@'%' IDENTIFIED BY '#{db_password}';"
end

#loggerObject



19
20
21
# File 'lib/anvil/mysql/user_creator.rb', line 19

def logger
  Anvil::Logger.new(self.class.name)
end

#scriptObject



15
16
17
# File 'lib/anvil/mysql/user_creator.rb', line 15

def script
  "mysql -u#{mysql_user} -p#{mysql_password} -h #{mysql_host} -P #{mysql_port} -e \"#{db_script}\""
end