Sha256: b252d21a8ee07d19af346c2595388e62477dbb9be78707fc54a0f5ebb183d114

Contents?: true

Size: 554 Bytes

Versions: 3

Compression:

Stored size: 554 Bytes

Contents

module RecordFilter
  class GroupBy
    attr_reader :column, :table

    def initialize(column, table)
      @column, @table = column, table
    end

    def to_sql
      table, column = @table, @column
      while column.is_a?(Hash)
        table = table.join_association(column.keys[0]).right_table
        column = column.values[0]
      end

      if (!table.has_column(column))
        raise ColumnNotFoundException.new("The column #{column} was not found in #{table.table_name}.")
      end

      "#{table.table_name}.#{column}"
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
aub-record_filter-0.1.2 lib/record_filter/group_by.rb
aub-record_filter-0.1.4 lib/record_filter/group_by.rb
outoftime-record_filter-0.1.3 lib/record_filter/group_by.rb