You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Base: read from known_attributes in respond_to_missing?
Prior to this commit, the `respond_to_missing?` implementation had a
conditional to supports attributes being able to be written to through
methods "did not respond to" (like `send("#{attr_name}=", value)`), as
well as `?`-suffixed predicate methods.
The `method_missing` implementation has a set of conditionals similar to
`respond_to_missing`, but with subtle variations through checking for an
attribute name's inclusion in `known_attributes` (attributes defined by
the Schema **or** assigned during `Base#load`) rather than the attribute
name's inclusion in `attributes` (the current instance's assigned
values, without any attributes declared in the Schema).
Without the implementation changes, the following tests introduced in
this commit fail:
```
1) Failure:
BaseTest#test_respond_to_known_attributes [test/cases/base_test.rb:972]:
Expected #<Person:0x000000011d0cdcf8 @attributes={}, @prefix_options={}, @persisted=false> (Person) to respond to #name=.
```
This commit changes the `respond_to_missing?` conditional to check for
the presence of the key in `known_attributes` rather than `attributes`
so that instances will respond to `=`-suffixed writers and `?`-suffixed
predicates for attributes that are declared in the resource's Schema
that have not yet been assigned to.
0 commit comments