Class: DB::Model::Statement::Limit
- Inherits:
-
Object
- Object
- DB::Model::Statement::Limit
- Defined in:
- lib/db/model/statement/limit.rb
Constant Summary collapse
- ONE =
self.new(1)
Instance Method Summary collapse
- #append_to(statement) ⇒ Object
- #first(count) ⇒ Object
-
#initialize(count, offset: nil) ⇒ Limit
constructor
A new instance of Limit.
Constructor Details
#initialize(count, offset: nil) ⇒ Limit
Returns a new instance of Limit.
10 11 12 13 |
# File 'lib/db/model/statement/limit.rb', line 10 def initialize(count, offset: nil) @count = count @offset = offset end |
Instance Method Details
#append_to(statement) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/db/model/statement/limit.rb', line 15 def append_to(statement) statement.clause("LIMIT") statement.literal(@count) if @offset statement.clause("OFFSET") statement.literal(@offset) end return statement end |
#first(count) ⇒ Object
27 28 29 |
# File 'lib/db/model/statement/limit.rb', line 27 def first(count) self.new(count, offset: @offset) end |