JsonApiClient / json_api_client

Build client libraries compliant with specification defined by jsonapi.org
MIT License
362 stars 186 forks source link

Paginator doesn't have accessor methods for page params #365

Open jaimeiniesta opened 4 years ago

jaimeiniesta commented 4 years ago

The README suggests the following can be done to customize the page parameters:

JsonApiClient::Paginating::Paginator.page_param = "number"
JsonApiClient::Paginating::Paginator.per_page_param = "size"

However, this fails because this paginator doesn't have accessor methods for these attributes:

/Users/jaime/.rvm/gems/ruby-2.3.7/gems/json_api_client-1.16.1/lib/json_api_client/paginating/paginator.rb:4:in `<class:Paginator>': undefined method `class_attribute' for JsonApiClient::Paginating::Paginator:Class (NoMethodError)
Did you mean?  class_variables
               class_variable_get
               class_variable_set
               class
               alias_attribute
        from /Users/jaime/.rvm/gems/ruby-2.3.7/gems/json_api_client-1.16.1/lib/json_api_client/paginating/paginator.rb:3:in `<module:Paginating>'
        from /Users/jaime/.rvm/gems/ruby-2.3.7/gems/json_api_client-1.16.1/lib/json_api_client/paginating/paginator.rb:2:in `<module:JsonApiClient>'
        from /Users/jaime/.rvm/gems/ruby-2.3.7/gems/json_api_client-1.16.1/lib/json_api_client/paginating/paginator.rb:1:in `<top (required)>'

The other paginator, NestedParamPaginator, does work can be customized like:

JsonApiClient::Paginating::NestedParamPaginator.page_param = "number"
JsonApiClient::Paginating::NestedParamPaginator.per_page_param = "size"