Sha256: fa3279df52bc82f8e917afa66c7d4c0a447851e28667efa4e3413dbe8f501f0a

Contents?: true

Size: 472 Bytes

Versions: 13

Compression:

Stored size: 472 Bytes

Contents

module ActiveHouse
  module Groupable
    extend ActiveSupport::Concern

    included do
      private

      def build_group_by_query_part
        "GROUP BY #{@grouping.join(', ')}" unless @grouping.empty?
      end
    end

    def initialize(*)
      @grouping = []
      super
    end

    def group_by(*fields)
      raise ArgumentError, 'wrong number of arguments' if fields.empty?
      chain_query grouping: (@grouping + fields.map(&:to_s)).uniq
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active_house-0.4.0 lib/active_house/groupable.rb
active_house-0.3.2 lib/active_house/groupable.rb
active_house-0.3.1 lib/active_house/groupable.rb
active_house-0.3.0 lib/active_house/groupable.rb
active_house-0.2.2 lib/active_house/groupable.rb
active_house-0.2.1 lib/active_house/groupable.rb
active_house-0.2.0 lib/active_house/groupable.rb
active_house-0.1.5 lib/active_house/groupable.rb
active_house-0.1.4 lib/active_house/groupable.rb
active_house-0.1.3 lib/active_house/groupable.rb
active_house-0.1.2 lib/active_house/groupable.rb
active_house-0.1.1 lib/active_house/groupable.rb
active_house-0.1.0 lib/active_house/groupable.rb