Sha256: 0b69f8953b2f6fd194d298783d490c77368086bb69ccbd5e05808c7a555feef9

Contents?: true

Size: 366 Bytes

Versions: 3

Compression:

Stored size: 366 Bytes

Contents


class Simple::SQL::Scope
  def order_by(sql_fragment)
    duplicate.send(:order_by!, sql_fragment)
  end

  private

  # Adjust sort order
  def order_by!(sql_fragment)
    @order_by_fragment = sql_fragment
    self
  end

  # called from to_sql
  def apply_order(sql)
    return sql unless @order_by_fragment
    "#{sql} ORDER BY #{@order_by_fragment}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple-sql-0.4.9 lib/simple/sql/scope/order.rb
simple-sql-0.4.8 lib/simple/sql/scope/order.rb
simple-sql-0.4.7 lib/simple/sql/scope/order.rb