Base: read from known_attributes in respond_to_missing?
          #450
        
          
      
      
        
          +47
        
        
          −2
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Prior to this commit, the
respond_to_missing?implementation had aconditional to supports attributes being able to be written to through
methods "did not respond to" (like
send("#{attr_name}=", value)), aswell as
?-suffixed predicate methods.The
method_missingimplementation has a set of conditionals similar torespond_to_missing, but with subtle variations through checking for anattribute name's inclusion in
known_attributes(attributes defined bythe Schema or assigned during
Base#load) rather than the attributename's inclusion in
attributes(the current instance's assignedvalues, without any attributes declared in the Schema).
Without the implementation changes, the following tests introduced in
this commit fail:
This commit changes the
respond_to_missing?conditional to check forthe presence of the key in
known_attributesrather thanattributesso that instances will respond to
=-suffixed writers and?-suffixedpredicates for attributes that are declared in the resource's Schema
that have not yet been assigned to.