Sha256: 268304841a03b9e6d7a1c959d4c027b24b70ce8e2c82a80b851a048600b020f3

Contents?: true

Size: 553 Bytes

Versions: 15

Compression:

Stored size: 553 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

15 entries across 15 versions & 1 rubygems

Version Path
simple-sql-0.5.4 lib/simple/sql/scope/order.rb
simple-sql-0.5.3 lib/simple/sql/scope/order.rb
simple-sql-0.4.41 lib/simple/sql/scope/order.rb
simple-sql-0.5.2 lib/simple/sql/scope/order.rb
simple-sql-0.4.40 lib/simple/sql/scope/order.rb
simple-sql-0.4.39 lib/simple/sql/scope/order.rb
simple-sql-0.4.38 lib/simple/sql/scope/order.rb
simple-sql-0.4.37 lib/simple/sql/scope/order.rb
simple-sql-0.4.36 lib/simple/sql/scope/order.rb
simple-sql-0.4.35 lib/simple/sql/scope/order.rb
simple-sql-0.5.0 lib/simple/sql/scope/order.rb
simple-sql-0.4.32 lib/simple/sql/scope/order.rb
simple-sql-0.4.31 lib/simple/sql/scope/order.rb
simple-sql-0.4.30 lib/simple/sql/scope/order.rb
simple-sql-0.4.29 lib/simple/sql/scope/order.rb