Skip to content

Instantly share code, notes, and snippets.

@girasquid
Created July 31, 2014 13:01
Show Gist options
  • Save girasquid/b48d2f9fb762a94c7d8e to your computer and use it in GitHub Desktop.
Save girasquid/b48d2f9fb762a94c7d8e to your computer and use it in GitHub Desktop.
require 'data_objects'
require 'data_mapper'
require 'dm-core'
require 'dm-do-adapter'
require 'do_postgres'
module DataMapper
class << self
attr_accessor :query_count
end
class Repository
alias_method :original_new_query, :new_query
def new_query(model, options = {})
DataMapper.query_count ||= 0
DataMapper.query_count += 1
original_new_query(model, options)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment