Class: OpenAPIRest::Operations::Paginate

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_rest/operations/paginate.rb

Overview

Rest paginate operation

Instance Method Summary collapse

Constructor Details

#initialize(query_builder) ⇒ Paginate

Returns a new instance of Paginate.



7
8
9
# File 'lib/openapi_rest/operations/paginate.rb', line 7

def initialize(query_builder)
  @query_builder = query_builder
end

Instance Method Details

#executeObject



11
12
13
14
15
16
# File 'lib/openapi_rest/operations/paginate.rb', line 11

def execute
  return if @query_builder.single?

  @query_builder.api_model.model = @query_builder.api_model.model.limit(@query_builder.limit)
                                                                 .offset(@query_builder.offset)
end