Class: ForestAdminDatasourceToolkit::Components::Query::Page
- Inherits:
-
Object
- Object
- ForestAdminDatasourceToolkit::Components::Query::Page
- Defined in:
- lib/forest_admin_datasource_toolkit/components/query/page.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
- #apply(records) ⇒ Object
-
#initialize(offset:, limit:) ⇒ Page
constructor
A new instance of Page.
- #to_h ⇒ Object
Constructor Details
#initialize(offset:, limit:) ⇒ Page
Returns a new instance of Page.
7 8 9 10 |
# File 'lib/forest_admin_datasource_toolkit/components/query/page.rb', line 7 def initialize(offset:, limit:) @offset = offset @limit = limit end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/forest_admin_datasource_toolkit/components/query/page.rb', line 5 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/forest_admin_datasource_toolkit/components/query/page.rb', line 5 def offset @offset end |
Instance Method Details
#apply(records) ⇒ Object
12 13 14 15 |
# File 'lib/forest_admin_datasource_toolkit/components/query/page.rb', line 12 def apply(records) end_index = @limit ? @offset + @limit : nil records[@offset...end_index] end |
#to_h ⇒ Object
17 18 19 |
# File 'lib/forest_admin_datasource_toolkit/components/query/page.rb', line 17 def to_h { offset: @offset, limit: @limit } end |