Class: ActivePgLog::ActiveTrigger
- Inherits:
-
Object
- Object
- ActivePgLog::ActiveTrigger
- Defined in:
- lib/active_pg_log/active_trigger.rb
Instance Attribute Summary collapse
-
#dados ⇒ Object
Returns the value of attribute dados.
Instance Method Summary collapse
- #include?(trigger_name, table_name) ⇒ Boolean
-
#initialize(connection) ⇒ ActiveTrigger
constructor
A new instance of ActiveTrigger.
- #query ⇒ Object
Constructor Details
#initialize(connection) ⇒ ActiveTrigger
Returns a new instance of ActiveTrigger.
4 5 6 |
# File 'lib/active_pg_log/active_trigger.rb', line 4 def initialize(connection) @dados = connection.select_all(query) end |
Instance Attribute Details
#dados ⇒ Object
Returns the value of attribute dados.
2 3 4 |
# File 'lib/active_pg_log/active_trigger.rb', line 2 def dados @dados end |
Instance Method Details
#include?(trigger_name, table_name) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/active_pg_log/active_trigger.rb', line 8 def include?(trigger_name, table_name) return false if !defined?(@dados.rows) || @dados.rows.size.zero? @dados.select { |e| e['table_name'] == table_name && e['trigger_name'] == trigger_name }.size.positive? end |
#query ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/active_pg_log/active_trigger.rb', line 14 def query %(select event_object_schema as table_schema, event_object_table as table_name, trigger_schema, trigger_name, string_agg(event_manipulation, ',') as event, action_timing as activation, action_condition as condition, action_statement as definition from information_schema.triggers group by 1,2,3,4,6,7,8 order by table_schema, table_name; ) end |