Class: Mysqlaudit::Actions
- Inherits:
-
Object
- Object
- Mysqlaudit::Actions
- Defined in:
- lib/mysqlaudit/actions.rb
Instance Method Summary collapse
-
#initialize(host, user, password, schema, table, drop = nil, statement = nil) ⇒ Actions
constructor
A new instance of Actions.
- #install ⇒ Object
- #rollback ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(host, user, password, schema, table, drop = nil, statement = nil) ⇒ Actions
Returns a new instance of Actions.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mysqlaudit/actions.rb', line 7 def initialize(host, user, password, schema, table, drop = nil, statement = nil) # def initialize(schema, table, options = {}) # options = {host: 'localhost', user: 'root', password: ''}.merge(options) $host = host $user = user $password = password $schema = schema $table = table $drop = drop $statement = statement @audit = Mysqlaudit::Audit.new($host, $user, $password, $schema) end |
Instance Method Details
#install ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mysqlaudit/actions.rb', line 22 def install() @audit.create_table() if !$table tables = @audit.get_tables() tables.each do | table | @audit.create_trigger(table, :insert) @audit.create_trigger(table, :update) @audit.create_trigger(table, :delete) end else @audit.create_trigger($table, :insert) @audit.create_trigger($table, :update) @audit.create_trigger($table, :delete) end end |
#rollback ⇒ Object
58 59 60 |
# File 'lib/mysqlaudit/actions.rb', line 58 def rollback() @audit.rollback($table, $statement.to_sym) end |
#uninstall ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mysqlaudit/actions.rb', line 39 def uninstall() if !$table tables = @audit.get_tables() tables.each do | table | @audit.drop_trigger(table, :insert) @audit.drop_trigger(table, :update) @audit.drop_trigger(table, :delete) end else @audit.drop_trigger($table, :insert) @audit.drop_trigger($table, :update) @audit.drop_trigger($table, :delete) end if $drop @audit.drop_table() end end |