Releases: jsmestad/jsonapi-consumer
Releases · jsmestad/jsonapi-consumer
Thread-safe custom headers for Rails users
The changes are not expected to impact users of v1.x, but since it's technically changing the API v2.x is appropriate.
Enhancements
- Allow
message
to be passed in when raising anyJSONAPI::Consumer::Error
class.- This is handy when a client wants to re-raise an error with additional information.
- Remove all
Object#send
in favor of the "more secure"Object#public_send
Bugfixes
- Custom Headers will now work correctly with threaded servers such as Puma or Unicorn thanks to the added
request_store
dependency. - A
custom_method
will now obeyResource#route_formatter
setting when generating custom endpoint paths.- For example:
custom_endpoint :publish_now, on: :member, request_method: :post
will now generatehttp://example.com/countries/1/publish-now
whenroute_formatter
is set to:dasherized_route
- For example:
Bugfix for class_attribute not defined
v1.0.0
Changes
Performance
Dynamic attribute definitions improvement (PR JsonApiClient/json_api_client#281)
Before:
user system total real
read: 1.090000 0.010000 1.100000 ( 1.091464)
write: 1.130000 0.000000 1.130000 ( 1.136750)
After:
user system total real
read: 0.020000 0.000000 0.020000 ( 0.016366)
write: 0.690000 0.000000 0.690000 ( 0.687914)
Features
- Return a QueryBuilder from HasMany associations instead of an Array (PR JsonApiClient/json_api_client#274 and Issue JsonApiClient/json_api_client#270)
- Support for custom header inheritance (PR JsonApiClient/json_api_client#280)
- Add Authorization helpers to base Resource:
JSONAPI::Consumer::Resource.authorize_with=
setsAuthorization=Bearer #{val}
headerJSONAPI::Consumer::Resource.authorize_with(jwt, &block)
same as above, but for only a single request.JSONAPI::Consumer::Resource.authorized?
returns true/false if Authorization is not emptyJSONAPI::Consumer::Resource.clear_authorization!
clears the Authorization headerJSONAPI::Consumer::Resource.authorized_as
returns the Authorization header
Bugfixes
- Fetch a HasOne relationship that was not included in the original query (JsonApiClient/json_api_client#244)