Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle UnknownAttributeError and put attributes to #unknown_attributes (
#23)
- Loading branch information
1 parent
cd1f6e7
commit 7628b24
Showing
6 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Unknown attributes | ||
|
||
Sometimes JSON structure changes and it contains more keys than attributes defined in your `StoreModel::Model` class. In such cases, "unknown" attributes can be found inside the `#unknown_attributes` hash: | ||
|
||
```ruby | ||
class Configuration | ||
include StoreModel::Model | ||
|
||
attribute :color, :string | ||
end | ||
|
||
configuration = Configuration.new(color: "red", archived: true) | ||
configuration.unknown_attributes # => { "archived" => true } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters