Sha256: a2e39dd22c9a5570debb3de823ee38dd33c56289115330fcebc37ae81b9ff130

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Timber
  module Contexts
    module SQLQueries
      class ActiveRecordSpecific < Context
        class Binds < DynamicValues
          attr_reader :log_subscriber, :binds

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

          private
            # Override values_array so that this is done in the background thread
            def values_array
              @values_array ||= binds.collect do |bind|
                name, value = render_bind(bind)
                {:name => name, :value => value}
              end
            end

            def render_bind(bind)
              if bind.is_a?(Array)
                # AR 4.2.X
                log_subscriber.render_bind(*bind)
              else
                log_subscriber.render_bind(bind)
              end
            end
        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_specific/binds.rb