Class: Mysqlaudit::Actions
- Inherits:
-
Object
- Object
- Mysqlaudit::Actions
- Defined in:
- lib/mysqlaudit/actions.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Actions
constructor
A new instance of Actions.
- #install ⇒ Object
- #rollback ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Actions
Returns a new instance of Actions.
7 8 9 10 11 12 13 14 15 |
# File 'lib/mysqlaudit/actions.rb', line 7 def initialize( = {}) .delete_if { |k, v| v.nil? } = {host: 'localhost', user: 'root', password: ''}.merge() @audit = Mysqlaudit::Audit.new([:host], [:user], [:password], [:schema]) end |
Instance Method Details
#install ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mysqlaudit/actions.rb', line 17 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
53 54 55 |
# File 'lib/mysqlaudit/actions.rb', line 53 def rollback() @audit.rollback([:table], [:statement]) end |
#uninstall ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mysqlaudit/actions.rb', line 34 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 |