Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#292 #254 making scopes unmodifiable #293

Merged
merged 5 commits into from
Aug 27, 2018

Conversation

gaorlov
Copy link
Collaborator

@gaorlov gaorlov commented Aug 24, 2018

When a scope is chained, the parent is modified. For example:

scope = Example::User.where( name: "Greg" )
scope.first

# scope is set to
#<JsonApiClient::Query::Builder:0x000055dafec45c50 @klass=Example::Client::User, @primary_key=nil, @pagination_params={"page"=>1, "per_page"=>1}, @path_params={}, @additional_params={}, @filters={:name=>"Greg"}, @includes=[], @orders=[], @fields=[], @to_a=[#<Example::Client::User:@attributes={"type"=>"users", "id"=>1, "name"=>"Greg"}>]>

scope.all
# will call find on whatever is already there and only return the first record

scope.paginate( page: 10, :per_page: 100).first
# will eat all the pagination params and return only the first record

Scopes should not be mutable

@senid231
Copy link
Member

I think we can merge this

@senid231 senid231 mentioned this pull request Aug 27, 2018
@gaorlov
Copy link
Collaborator Author

gaorlov commented Aug 27, 2018

@senid231 what's the protocol for version revving? merge into master and then bump? also: should this be a minor or a patch version bump?

@gaorlov gaorlov merged commit fc06c87 into JsonApiClient:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants