Module: Shamu::Entities::ListScope::Paging

Defined in:
lib/shamu/entities/list_scope/paging.rb

Overview

Include paging parsing and attributes. Adds the following attributes to the list scope:

class UsersListScope < Shamu::Entities::ListScope
  include Shamu::Entities::ListScope::Paging
end

scope = UsersListScope.coerce!( params )
scope.page      # => 1
scope.per_page # => 25

Attributes collapse

Instance Method Summary collapse

Instance Attribute Details

#default_per_pageInteger

Returns default number of records per page if not provided.

Returns:

  • (Integer)

    default number of records per page if not provided.



# File 'lib/shamu/entities/list_scope/paging.rb', line 29

#pageInteger

Returns the current page number. 1 based.

Returns:

  • (Integer)

    the current page number. 1 based.



# File 'lib/shamu/entities/list_scope/paging.rb', line 23

#per_pageInteger

Returns number of records per page.

Returns:

  • (Integer)

    number of records per page.



# File 'lib/shamu/entities/list_scope/paging.rb', line 26

Instance Method Details

#paged?Boolean

Returns true if the scope is paged.

Returns:

  • (Boolean)

    true if the scope is paged.



44
45
46
# File 'lib/shamu/entities/list_scope/paging.rb', line 44

def paged?
  !!page || !!per_page
end