Releases: Manfred/Reynard
v0.10.0
- Updates model naming to reduce the changes of model name collisions
- Increases the minimal supported Ruby version to 3.1
Upgrade notes
Model naming has been changed slightly so if you take advantage of shadow definiting certain models (ie. if your code defines anything in Reynard::Models
), you may have to rename that model to make it match the new model naming rules.
v0.9.0
- Make
Reynard::Model
a subclass ofBasicObject
so we get less in the way of potential attribute names likedisplay
. - Added
Model#empty?
for testing if the attributes are empty. - Improved error message when Reynard model is instantiated with an array instead of a hash.
v0.8.2
v0.8.1
v0.8.0
- Property values from a payload are now stored as a
Hash
in the model instance to support multiple access methods. - Added an inflector so properties which don't use
snake_case
likefirstName
can now be accessed through thefirst_name
method. - Added a way to register irregular snake-cases with the inflector, for example:
reynard.snake_cases({ '1st-class' => 'first_class' })
. This particular example allows the1st-class
property on a model to be accessed through thefirst_class
method. See the README for more examples and details.
Upgrade notes
It's possible that Reynard now throws a NoMethodError
where it previously returned nil
, this may be caused by the fact that the payload is missing an optional value. You can either use try(:method_name)
in Ruby on Rails, check if the attribute is accessible with respond_to?(:method_name)
or use the []
accessor ["method_name"]
, note that you probably have to use a string in the last example.
v0.7.0
v0.6.0
- Added
Reynard::Http::Response#parsed_body
so consumers don't have to parse response bodies to access the raw data. - Added status accessors to
Reynard::Http::Response
, accessors are:informational?
,success?
,redirection?
,client_error?
, andserver_error?
. These test respectively for 1xx, 2xx, 3xx, 4xx, and 5xx response codes. - Changed
Reynard::ObjectBuilder
to build instantiated models based on schemas in the specification and support nested resources.
Upgrade notes
If you are already using Reynard::Http::Response#object
for responses that aren't just one deep arrays or objects you will notice that propery accesors will now return Reynard::Model
instances instead of of Hash
.
For example:
def print_books
response = request.perform
return unless response.success
response.object.books.each do |book|
puts "#{book.title} (#{book.author.name})"
end
end