Module: Shamu::Entities::ListScope::WindowPaging

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

Overview

Limit/offset style paging using first/after naming conventions typical in GraphQL implementations.

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

scope = UsersListScope.coerce!( params )
scope.first    # => 25
scope.after    # => 75

Attributes collapse

Instance Method Summary collapse

Instance Attribute Details

#afterInteger

Returns the number of records to skip from the beginning.

Returns:

  • (Integer)

    the number of records to skip from the beginning.



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

#beforeInteger

Returns the number of records to skip from the end.

Returns:

  • (Integer)

    the number of records to skip from the end.



# File 'lib/shamu/entities/list_scope/window_paging.rb', line 32

#firstInteger

Returns get the first n records.

Returns:

  • (Integer)

    get the first n records.



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

#lastInteger

Returns get the last n records.

Returns:

  • (Integer)

    get the last n records.



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

Instance Method Details

#window_paged?Boolean

Returns true if the scope is paged.

Returns:

  • (Boolean)

    true if the scope is paged.



71
72
73
# File 'lib/shamu/entities/list_scope/window_paging.rb', line 71

def window_paged?
  first? || last?
end