Sha256: 637896e6832b02291c9e633947cae3c8d5d100dda8e081aaf9398b31a78b0b8b

Contents?: true

Size: 654 Bytes

Versions: 2

Compression:

Stored size: 654 Bytes

Contents

require 'active_record'

ActiveSupport.on_load(:active_record) do
  class ActiveRecord::Base
    def self.query_limiter(options={})
      class_attribute :max_limit

      def self.limiter_scope
        limit(self.max_limit || 5)
      end
      
      unless options[:without_default_scope]
        default_scope { limiter_scope }
      end

      def self.max_query_limit(limit)
        self.max_limit = limit
      end

    end
  end
end

module QueryLimiter
    class LimitQuery
        def self.limit_query(max_limit=5)
            puts "Query limit gem limits results of a query by #{max_limit}"
            return max_limit
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
query_limiter-0.1.3 lib/query_limiter/limiter.rb
query_limiter-0.1.2 lib/query_limiter/limiter.rb