Module: Rubyists::PgtOutbox
- Included in:
- Function
- Defined in:
- lib/sequel/pgt_outbox.rb,
lib/sequel/pgt_outbox/table.rb,
lib/sequel/pgt_outbox/trigger.rb,
lib/sequel/pgt_outbox/version.rb,
lib/sequel/pgt_outbox/function.rb
Overview
Top-level module for the PgtOutbox gem
Defined Under Namespace
Classes: Function, Table, Trigger
Constant Summary collapse
- DEFINITION =
proc do def pgt_outbox_setup(table, opts = {}) outbox = Rubyists::PgtOutbox.outbox_table(table, self, opts:) pgt_created_at outbox.name, outbox.created_column pgt_updated_at outbox.name, outbox.updated_column outbox.function.name end def pgt_outbox_events(table, function, events: %i[insert update delete], when: nil, opts: {}) Rubyists::PgtOutbox::Trigger.create!(self, table, function, events:, opts: opts.merge(when:)) end end
- VERSION =
x-release-please-start-version
'0.2.7'
Class Method Summary collapse
Instance Method Summary collapse
-
#depth_guard_clause(depth_limit = nil) ⇒ Object
Guards against recursive triggers NOTE: Taken from sequel_postgresql_triggers.
-
#mangled_table_name(db, table) ⇒ Object
Mangle the schema name so it can be used in an unquoted_identifier NOTE: Taken from sequel_postgresql_triggers.
Class Method Details
Instance Method Details
#depth_guard_clause(depth_limit = nil) ⇒ Object
Guards against recursive triggers NOTE: Taken from sequel_postgresql_triggers
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sequel/pgt_outbox.rb', line 35 def depth_guard_clause(depth_limit = nil) return unless depth_limit depth_limit = 1 if depth_limit == true depth_limit = depth_limit.to_i raise ArgumentError, ':trigger_depth_limit option must be at least 1' unless depth_limit >= 1 <<~SQL IF pg_trigger_depth() > #{depth_limit} THEN RETURN NEW; END IF; SQL end |
#mangled_table_name(db, table) ⇒ Object
Mangle the schema name so it can be used in an unquoted_identifier NOTE: Taken from sequel_postgresql_triggers
52 53 54 |
# File 'lib/sequel/pgt_outbox.rb', line 52 def mangled_table_name(db, table) db.send(:quote_schema_table, table).gsub('"', '').gsub(/[^A-Za-z0-9]/, '_').gsub(/_+/, '_') end |