Class: RecordFilter::GroupBy
- Inherits:
-
Object
- Object
- RecordFilter::GroupBy
- Defined in:
- lib/record_filter/group_by.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(column, table) ⇒ GroupBy
constructor
A new instance of GroupBy.
- #to_sql ⇒ Object
Constructor Details
#initialize(column, table) ⇒ GroupBy
Returns a new instance of GroupBy.
5 6 7 |
# File 'lib/record_filter/group_by.rb', line 5 def initialize(column, table) @column, @table = column, table end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
3 4 5 |
# File 'lib/record_filter/group_by.rb', line 3 def column @column end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
3 4 5 |
# File 'lib/record_filter/group_by.rb', line 3 def table @table end |
Instance Method Details
#to_sql ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/record_filter/group_by.rb', line 9 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_alias}.#{column}" end |