Class: AdminBits::AdminResource::Paginator
- Inherits:
-
Object
- Object
- AdminBits::AdminResource::Paginator
- Defined in:
- lib/admin_bits/admin_resource/paginator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(resource, page, options) ⇒ Paginator
constructor
A new instance of Paginator.
- #paginate ⇒ Object
Constructor Details
#initialize(resource, page, options) ⇒ Paginator
Returns a new instance of Paginator.
4 5 6 7 8 |
# File 'lib/admin_bits/admin_resource/paginator.rb', line 4 def initialize(resource, page, ) @resource = resource @page = page || 1 @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/admin_bits/admin_resource/paginator.rb', line 2 def @options end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
2 3 4 |
# File 'lib/admin_bits/admin_resource/paginator.rb', line 2 def page @page end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
2 3 4 |
# File 'lib/admin_bits/admin_resource/paginator.rb', line 2 def resource @resource end |
Instance Method Details
#paginate ⇒ Object
10 11 12 13 |
# File 'lib/admin_bits/admin_resource/paginator.rb', line 10 def paginate per_page = 30 resource.slice((page - 1) * per_page, page * per_page) end |