Sha256: 56556df94c5a8b4eeb8a161443e9e2698d8b999c6869b79f5de4d932df0bb2a0

Contents?: true

Size: 555 Bytes

Versions: 19

Compression:

Stored size: 555 Bytes

Contents


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

  def limit(count)
    duplicate.send(:limit!, count)
  end

  private

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

  # Adjust sort order
  def limit!(count)
    @limit = count
    self
  end

  # called from to_sql
  def apply_order_and_limit(sql)
    sql = "#{sql} ORDER BY #{@order_by_fragment}" if @order_by_fragment
    sql = "#{sql} LIMIT #{@limit}" if @limit

    sql
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
simple-sql-0.4.28 lib/simple/sql/scope/order.rb
simple-sql-0.4.27 lib/simple/sql/scope/order.rb
simple-sql-0.4.26 lib/simple/sql/scope/order.rb
simple-sql-0.4.25 lib/simple/sql/scope/order.rb
simple-sql-0.4.24 lib/simple/sql/scope/order.rb
simple-sql-0.4.23 lib/simple/sql/scope/order.rb
simple-sql-0.4.22 lib/simple/sql/scope/order.rb
simple-sql-0.4.21 lib/simple/sql/scope/order.rb
simple-sql-0.4.20 lib/simple/sql/scope/order.rb
simple-sql-0.4.19 lib/simple/sql/scope/order.rb
simple-sql-0.4.18 lib/simple/sql/scope/order.rb
simple-sql-0.4.17 lib/simple/sql/scope/order.rb
simple-sql-0.4.16 lib/simple/sql/scope/order.rb
simple-sql-0.4.15 lib/simple/sql/scope/order.rb
simple-sql-0.4.14 lib/simple/sql/scope/order.rb
simple-sql-0.4.13 lib/simple/sql/scope/order.rb
simple-sql-0.4.12 lib/simple/sql/scope/order.rb
simple-sql-0.4.11 lib/simple/sql/scope/order.rb
simple-sql-0.4.10 lib/simple/sql/scope/order.rb