-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
wontfixThis will not be worked onThis will not be worked on
Description
An API is expected to return following result.
{
"age_range": {
"max": 30,
"min": 20
}
}An instance which implemented with MyApiClient returns that result as Sawyer::Resource.
result = ApiClient.request
result[:max] # => 30However, if the API returns following result, above execution will unexpected result.
{
"age_range": {
"min": 20
}
}result = ApiClient.request
result[:max] # => [:min, 20]The cause is into the Sawyer::Resouce implementation. Sawyer::Resouce#[] calls #method_missing and searches the key from inner fields.
Ordinarily it will return nil if does not find the key.
However, :max is Enumerable module instance so it will happen that calls Enumerable#max method.
Metadata
Metadata
Assignees
Labels
wontfixThis will not be worked onThis will not be worked on