Sha256: 7f7c2a081d84cf3b331b184c0fc226e57fddfc8e2f135ca79072e2369397fac9

Contents?: true

Size: 527 Bytes

Versions: 8

Compression:

Stored size: 527 Bytes

Contents

# encoding: UTF-8

require 'forwardable'
require 'enumerator'

module ArelHelpers
  class QueryBuilder
    extend Forwardable
    include Enumerable

    attr_reader :query
    def_delegators :@query, :to_a, :to_sql, :each

    TERMINAL_METHODS = [:count, :first, :last]
    TERMINAL_METHODS << :pluck if ActiveRecord::VERSION::MAJOR >= 4

    def_delegators :@query, *TERMINAL_METHODS

    def initialize(query)
      @query = query
    end

    protected

    def reflect(query)
      self.class.new(query)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arel-helpers-2.4.0 lib/arel-helpers/query_builder.rb
arel-helpers-2.3.0 lib/arel-helpers/query_builder.rb
arel-helpers-2.2.0 lib/arel-helpers/query_builder.rb
arel-helpers-2.1.1 lib/arel-helpers/query_builder.rb
arel-helpers-2.1.0 lib/arel-helpers/query_builder.rb
arel-helpers-2.0.2 lib/arel-helpers/query_builder.rb
arel-helpers-2.0.1 lib/arel-helpers/query_builder.rb
arel-helpers-2.0.0 lib/arel-helpers/query_builder.rb