Sha256: 3cd654687f9b5dc7b15bd6f47b02ba4b599f39f18867bbb8f20a07d76b5d6d91

Contents?: true

Size: 567 Bytes

Versions: 4

Compression:

Stored size: 567 Bytes

Contents

require "rom-sql"

module ROM
  class Relation
    # Monkey patch ROM::SQL to support query logs until an official API is available
    module Instrumentation
      def self.included(klass)
        klass.option :notifications, reader: true, optional: false, default: proc {
          <%= config[:camel_cased_app_name] %>::Container[:notifications]
        }
      end

      def to_a
        notifications.instrument(:sql, name: name.relation, query: dataset.sql) do
          super
        end
      end
    end

    SQL::Relation.include(Instrumentation)
  end
end

Version data entries

4 entries across 2 versions & 1 rubygems

Version Path
dry-web-roda-0.6.2 lib/dry/web/roda/skeletons/flat_project/lib/rom/instrumentation.rb.tt
dry-web-roda-0.6.2 lib/dry/web/roda/skeletons/umbrella_project/lib/rom/instrumentation.rb.tt
dry-web-roda-0.6.1 lib/dry/web/roda/skeletons/flat_project/lib/rom/instrumentation.rb.tt
dry-web-roda-0.6.1 lib/dry/web/roda/skeletons/umbrella_project/lib/rom/instrumentation.rb.tt