Sha256: 4cccba9481701192f61b50d07162acd24e81f10d269bbb2f4f7ed6157527f1e6

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

module Timber
  module Contexts
    module SQLQueries
      class ActiveRecord < SQLQuery
        attr_reader :log_subscriber, :event

        def initialize(log_subscriber, event)
          # Initialize should be as fast as possible since it is executed inline.
          # Hence the lazy methods below.
          @log_subscriber = log_subscriber
          @event = event
          super()
        end

        def sql
          @sql ||= payload[:sql].try(:strip)
        end

        def time_ms
          @time_ms ||= event.duration
        end

        private
          def payload
            event.payload
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/contexts/sql_queries/active_record.rb