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? } $options = {host: 'localhost', user: 'root', password: ''}.merge() @audit = Mysqlaudit::Audit.new($options[:host], $options[:user], $options[:password], $options[: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 !$options[: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($options[:table], :insert) @audit.create_trigger($options[:table], :update) @audit.create_trigger($options[:table], :delete) end end |
#rollback ⇒ Object
53 54 55 |
# File 'lib/mysqlaudit/actions.rb', line 53 def rollback() @audit.rollback($options[:table], $options[: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 !$options[: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($options[:table], :insert) @audit.drop_trigger($options[:table], :update) @audit.drop_trigger($options[:table], :delete) end if $options[:drop] @audit.drop_table() end end |