Sha256: 32b8471c2bbf2803d414b3cf4eacccd6465cb0843ad8745699baa7c71f8dab6a

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

module Octoshark
  module ActiveRecordBase
    extend ActiveSupport::Concern

    included do
      class << self
        alias_method_chain :establish_connection, :octoshark
      end
    end

    module ClassMethods
      def establish_connection_with_octoshark(*args)
        establish_connection_without_octoshark(*args)
        Octoshark.reload! if Octoshark.configured?
      end
    end
  end

  module ActiveRecordAbstractAdapter
    attr_accessor :connection_name

    def log(sql, name = "SQL", *other_args)
      if connection_name
        name = "[Octoshark: #{connection_name}] #{name}"
      end

      super(sql, name, *other_args)
    end
  end
end

ActiveRecord::Base.send(:include, Octoshark::ActiveRecordBase)
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:prepend, Octoshark::ActiveRecordAbstractAdapter)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
octoshark-0.0.6 lib/octoshark/active_record_extensions.rb