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.
27 28 29 30 |
# File 'lib/db/model/statement/limit.rb', line 27 def initialize(count, offset: nil) @count = count @offset = offset end |
Instance Method Details
#append_to(statement) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/db/model/statement/limit.rb', line 32 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
44 45 46 |
# File 'lib/db/model/statement/limit.rb', line 44 def first(count) self.new(count, offset: @offset) end |