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
Merge 0-10-stable into master (to fix breaking change). (#2023)
* Merge pull request #1990 from mxie/mx-result-typo
Fix typos and capitalization in Relationship Links docs [ci skip]
* Merge pull request #1992 from ojiry/bump_ruby_versions
Run tests by Ruby 2.2.6 and 2.3.3
* Merge pull request #1994 from bf4/promote_architecture
Promote important architecture description that answers a lot of questions we get
Conflicts:
docs/ARCHITECTURE.md
* Merge pull request #1999 from bf4/typos
Fix typos [ci skip]
* Merge pull request #2000 from berfarah/patch-1
Link to 0.10.3 tag instead of `master` branch
* Merge pull request #2007 from bf4/check_ci
Test was failing due to change in JSON exception message when parsing empty string
* Swap out KeyTransform for CaseTransform (#1993)
* delete KeyTransform, use CaseTransform
* added changelog
Conflicts:
CHANGELOG.md
* Merge pull request #2005 from kofronpi/support-ruby-2.4
Update jsonapi runtime dependency to 0.1.1.beta6
* Bump to v0.10.4
* Merge pull request #2018 from rails-api/bump_version
Bump to v0.10.4 [ci skip]
Conflicts:
CHANGELOG.md
* Merge pull request #2019 from bf4/fix_method_redefined_warning
Fix AMS warnings
* Merge pull request #2020 from bf4/silence_grape_warnings
Silence Grape warnings
* Merge pull request #2017 from bf4/remove_warnings
Fix mt6 assert_nil warnings
* Updated isolated tests to assert correct behavior. (#2010)
* Updated isolated tests to assert correct behavior.
* Added check to get unsafe params if rails version is great than 5
* Merge pull request #2012 from bf4/cleanup_isolated_jsonapi_renderer_tests_a_bit
Cleanup assertions in isolated jsonapi renderer tests a bit
* Add Model#attributes helper; make test attributes explicit
* Fix model attributes accessors
* Fix typos
* Randomize testing of compatibility layer against regressions
* Test bugfix
* Add CHANGELOG
* Merge pull request #1981 from groyoh/link_doc
Fix relationship links doc
Conflicts:
CHANGELOG.md
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,16 @@ Breaking changes:
6
6
7
7
Features:
8
8
9
-
-[#1982](https://github.com/rails-api/active_model_serializers/pull/1982) Add ActiveModelSerializers::Model.attributes to configure PORO attributes. (@bf4)
9
+
-[#2021](https://github.com/rails-api/active_model_serializers/pull/2021)ActiveModelSerializers::Model#attributes. Originally in [#1982](https://github.com/rails-api/active_model_serializers/pull/1982). (@bf4)
10
10
11
11
Fixes:
12
12
13
-
-[#1984](https://github.com/rails-api/active_model_serializers/pull/1984) Mutation of ActiveModelSerializers::Model now changes the attributes. (@bf4)
13
+
-[#2022](https://github.com/rails-api/active_model_serializers/pull/2022) Mutation of ActiveModelSerializers::Model now changes the attributes. Originally in [#1984](https://github.com/rails-api/active_model_serializers/pull/1984). (@bf4)
14
14
15
15
Misc:
16
16
17
+
-[#2021](https://github.com/rails-api/active_model_serializers/pull/2021) Make test attributes explicit. Tests have Model#associations. (@bf4)
17
18
-[#1981](https://github.com/rails-api/active_model_serializers/pull/1981) Fix relationship link documentation. (@groyoh)
18
-
-[#1984](https://github.com/rails-api/active_model_serializers/pull/1984) Make test attributes explicit. Test models have 'associations' support. (@bf4)
Copy file name to clipboardExpand all lines: docs/howto/serialize_poro.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,16 @@
2
2
3
3
# How to serialize a Plain-Old Ruby Object (PORO)
4
4
5
-
When you are first getting started with ActiveModelSerializers, it may seem only `ActiveRecord::Base` objects can be serializable, but pretty much any object can be serializable with ActiveModelSerializers. Here is an example of a PORO that is serializable:
5
+
When you are first getting started with ActiveModelSerializers, it may seem only `ActiveRecord::Base` objects can be serializable,
6
+
but pretty much any object can be serializable with ActiveModelSerializers.
7
+
Here is an example of a PORO that is serializable in most situations:
8
+
6
9
```ruby
7
10
# my_model.rb
8
11
classMyModel
9
12
alias:read_attribute_for_serialization:send
10
13
attr_accessor:id, :name, :level
11
-
14
+
12
15
definitialize(attributes)
13
16
@id= attributes[:id]
14
17
@name= attributes[:name]
@@ -21,12 +24,22 @@ class MyModel
21
24
end
22
25
```
23
26
24
-
Fortunately, ActiveModelSerializers provides a [`ActiveModelSerializers::Model`](https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model_serializers/model.rb) which you can use in production code that will make your PORO a lot cleaner. The above code now becomes:
27
+
The [ActiveModel::Serializer::Lint::Tests](../../lib/active_model/serializer/lint.rb)
28
+
define and validate which methods ActiveModelSerializers expects to be implemented.
29
+
30
+
An implementation of the complete spec is included either for use or as reference:
0 commit comments