active_model_serializers 0.8.3 → 0.10.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +18 -20
- data/CHANGELOG.md +8 -67
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +14 -1
- data/{MIT-LICENSE.txt → LICENSE.txt} +3 -2
- data/README.md +169 -495
- data/Rakefile +6 -12
- data/active_model_serializers.gemspec +21 -19
- data/lib/action_controller/serialization.rb +36 -27
- data/lib/active_model/serializer/adapter/flatten_json.rb +12 -0
- data/lib/active_model/serializer/adapter/fragment_cache.rb +78 -0
- data/lib/active_model/serializer/adapter/json/fragment_cache.rb +15 -0
- data/lib/active_model/serializer/adapter/json.rb +50 -0
- data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +23 -0
- data/lib/active_model/serializer/adapter/json_api.rb +156 -0
- data/lib/active_model/serializer/adapter/null.rb +11 -0
- data/lib/active_model/serializer/adapter.rb +96 -0
- data/lib/active_model/serializer/array_serializer.rb +35 -0
- data/lib/active_model/serializer/configuration.rb +13 -0
- data/lib/active_model/serializer/fieldset.rb +40 -0
- data/lib/active_model/serializer/railtie.rb +8 -0
- data/lib/active_model/{serializers → serializer}/version.rb +1 -1
- data/lib/active_model/serializer.rb +177 -440
- data/lib/active_model_serializers.rb +10 -86
- data/lib/generators/serializer/USAGE +0 -3
- data/lib/generators/serializer/resource_override.rb +12 -0
- data/lib/generators/serializer/serializer_generator.rb +1 -6
- data/lib/generators/serializer/templates/serializer.rb +2 -13
- data/test/action_controller/adapter_selector_test.rb +53 -0
- data/test/action_controller/explicit_serializer_test.rb +134 -0
- data/test/action_controller/json_api_linked_test.rb +179 -0
- data/test/action_controller/rescue_from_test.rb +32 -0
- data/test/{serialization_scope_name_test.rb → action_controller/serialization_scope_name_test.rb} +7 -11
- data/test/action_controller/serialization_test.rb +383 -0
- data/test/adapter/fragment_cache_test.rb +27 -0
- data/test/adapter/json/belongs_to_test.rb +48 -0
- data/test/adapter/json/collection_test.rb +73 -0
- data/test/adapter/json/has_many_test.rb +36 -0
- data/test/adapter/json_api/belongs_to_test.rb +157 -0
- data/test/adapter/json_api/collection_test.rb +96 -0
- data/test/adapter/json_api/has_many_embed_ids_test.rb +45 -0
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +98 -0
- data/test/adapter/json_api/has_many_test.rb +110 -0
- data/test/adapter/json_api/has_one_test.rb +61 -0
- data/test/adapter/json_api/linked_test.rb +283 -0
- data/test/adapter/json_test.rb +34 -0
- data/test/adapter/null_test.rb +25 -0
- data/test/adapter_test.rb +43 -0
- data/test/array_serializer_test.rb +31 -63
- data/test/fixtures/poro.rb +230 -0
- data/test/generators/scaffold_controller_generator_test.rb +24 -0
- data/test/{generators_test.rb → generators/serializer_generator_test.rb} +2 -36
- data/test/serializers/adapter_for_test.rb +50 -0
- data/test/serializers/associations_test.rb +127 -0
- data/test/serializers/attribute_test.rb +38 -0
- data/test/serializers/attributes_test.rb +63 -0
- data/test/serializers/cache_test.rb +138 -0
- data/test/serializers/configuration_test.rb +15 -0
- data/test/serializers/fieldset_test.rb +26 -0
- data/test/serializers/meta_test.rb +107 -0
- data/test/serializers/options_test.rb +21 -0
- data/test/serializers/serializer_for_test.rb +65 -0
- data/test/serializers/urls_test.rb +26 -0
- data/test/test_helper.rb +28 -16
- metadata +109 -43
- data/DESIGN.textile +0 -586
- data/Gemfile.edge +0 -9
- data/bench/perf.rb +0 -43
- data/cruft.md +0 -19
- data/lib/active_model/array_serializer.rb +0 -104
- data/lib/active_model/serializer/associations.rb +0 -233
- data/lib/active_record/serializer_override.rb +0 -16
- data/lib/generators/resource_override.rb +0 -13
- data/test/association_test.rb +0 -592
- data/test/caching_test.rb +0 -96
- data/test/no_serialization_scope_test.rb +0 -34
- data/test/serialization_test.rb +0 -392
- data/test/serializer_support_test.rb +0 -51
- data/test/serializer_test.rb +0 -1465
- data/test/test_fakes.rb +0 -217
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47b346a9a30d6c7e246505a4b48e3c8dd593c2a6
|
4
|
+
data.tar.gz: 74a94269fb1ffd10b1e30b65cd99e43ca3a62b30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61c621fc667fc3e1e168e50c4af8f267f4b7e3e82ce634d2555e814b2dde4a4514a9033cfa6f917b225bcc01b1f86fee36625a74e4a5d3dbeffc4209ff17aa70
|
7
|
+
data.tar.gz: a365c42818a1d413d10d78abce01954160879249b6b4e6119db93178d54aa4b608c026c730b2da2f00af7c77537a1260a506ed8fbf8cecf73341f90d437b5f89
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,28 +1,26 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
3
|
+
sudo: false
|
4
|
+
|
2
5
|
rvm:
|
3
|
-
- 1.8.7
|
4
|
-
- 1.9.2
|
5
6
|
- 1.9.3
|
6
7
|
- 2.0.0
|
7
|
-
-
|
8
|
-
-
|
8
|
+
- 2.1
|
9
|
+
- 2.2
|
9
10
|
- jruby-19mode
|
10
11
|
- rbx-2
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
- ruby-head
|
13
|
+
|
14
|
+
install:
|
15
|
+
- bundle install --retry=3
|
16
|
+
|
17
|
+
env:
|
18
|
+
- "RAILS_VERSION=4.0"
|
19
|
+
- "RAILS_VERSION=4.1"
|
20
|
+
- "RAILS_VERSION=4.2"
|
21
|
+
- "RAILS_VERSION=master"
|
22
|
+
|
14
23
|
matrix:
|
15
24
|
allow_failures:
|
16
|
-
-
|
17
|
-
|
18
|
-
# Edge Rails is only compatible with 1.9.3
|
19
|
-
- gemfile: Gemfile.edge
|
20
|
-
rvm: 1.8.7
|
21
|
-
- gemfile: Gemfile.edge
|
22
|
-
rvm: 1.9.2
|
23
|
-
- gemfile: Gemfile.edge
|
24
|
-
rvm: ree
|
25
|
-
- gemfile: Gemfile.edge
|
26
|
-
rvm: jruby-18mode
|
27
|
-
- gemfile: Gemfile.edge
|
28
|
-
rvm: rbx-18mode
|
25
|
+
- rvm: ruby-head
|
26
|
+
- env: "RAILS_VERSION=master"
|
data/CHANGELOG.md
CHANGED
@@ -1,67 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
*
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
* Attributes can now have optional types.
|
10
|
-
|
11
|
-
* A new DefaultSerializer ensures that POROs behave the same way as ActiveModels.
|
12
|
-
|
13
|
-
* If you wish to override ActiveRecord::Base#to_Json, you can now require
|
14
|
-
'active_record/serializer_override'. We don't recommend you do this, but
|
15
|
-
many users do, so we've left it optional.
|
16
|
-
|
17
|
-
* Fixed a bug where ActionController wouldn't always have MimeResponds.
|
18
|
-
|
19
|
-
* An optinal caching feature allows you to cache JSON & hashes that AMS uses.
|
20
|
-
Adding 'cached true' to your Serializers will turn on this cache.
|
21
|
-
|
22
|
-
* URL helpers used inside of Engines now work properly.
|
23
|
-
|
24
|
-
* Serializers now can filter attributes with `only` and `except`:
|
25
|
-
|
26
|
-
```
|
27
|
-
UserSerializer.new(user, only: [:first_name, :last_name])
|
28
|
-
UserSerializer.new(user, except: :first_name)
|
29
|
-
```
|
30
|
-
|
31
|
-
* Basic Mongoid support. We now include our mixins in the right place.
|
32
|
-
|
33
|
-
* On Ruby 1.8, we now generate an `id` method that properly serializes `id`
|
34
|
-
columns. See issue #127 for more.
|
35
|
-
|
36
|
-
* Add an alias for `scope` method to be the name of the context. By default
|
37
|
-
this is `current_user`. The name is automatically set when using
|
38
|
-
`serialization_scope` in the controller.
|
39
|
-
|
40
|
-
* Pass through serialization options (such as `:include`) when a model
|
41
|
-
has no serializer defined.
|
42
|
-
|
43
|
-
# VERSION 0.7.0
|
44
|
-
|
45
|
-
* ```embed_key``` option to allow embedding by attributes other than IDs
|
46
|
-
* Fix rendering nil with custom serializer
|
47
|
-
* Fix global ```self.root = false```
|
48
|
-
* Add support for specifying the serializer for an association as a String
|
49
|
-
* Able to specify keys on the attributes method
|
50
|
-
* Serializer Reloading via ActiveSupport::DescendantsTracker
|
51
|
-
* Reduce double map to once; Fixes datamapper eager loading.
|
52
|
-
|
53
|
-
# VERSION 0.6.0
|
54
|
-
|
55
|
-
* Serialize sets properly
|
56
|
-
* Add root option to ArraySerializer
|
57
|
-
* Support polymorphic associations
|
58
|
-
* Support :each_serializer in ArraySerializer
|
59
|
-
* Add `scope` method to easily access the scope in the serializer
|
60
|
-
* Fix regression with Rails 3.2.6; add Rails 4 support
|
61
|
-
* Allow serialization_scope to be disabled with serialization_scope nil
|
62
|
-
* Array serializer should support pure ruby objects besides serializers
|
63
|
-
|
64
|
-
# VERSION 0.5.0 (May 16, 2012)
|
65
|
-
|
66
|
-
* First tagged version
|
67
|
-
* Changes generators to always generate an ApplicationSerializer
|
1
|
+
### 0.10.0
|
2
|
+
|
3
|
+
* adds support for `meta` and `meta_key` [@kurko]
|
4
|
+
* adds method to override association [adcb99e, @kurko]
|
5
|
+
* adds `has_one` attribute for backwards compatibility [@ggordon]
|
6
|
+
* updates JSON API support to RC3 [@mateomurphy]
|
7
|
+
* adds fragment cache support [@joaomdmoura]
|
8
|
+
* adds cache support to attributes and associations [@joaomdmoura]
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
## How can I help?
|
2
|
+
|
3
|
+
Everyone is encouraged to open issues that are affecting you: bugs, ideas, performance problems – everything helps!
|
4
|
+
|
5
|
+
The first place to start is by looking at our [GitHub Issues](https://github.com/rails-api/active_model_serializers/issues).
|
6
|
+
|
7
|
+
The vast majority of development is happening under the `master` branch, currently slated for release as `0.10.x`. This is where we would suggest you start.
|
8
|
+
|
9
|
+
Fixing bugs is extraordinarily helpful and requires the least familiarity with AMS. Look for issues labeled [**Needs Bug Verification**](https://github.com/rails-api/active_model_serializers/labels/Needs%20Bug%20Verification) and [**Bug**](https://github.com/rails-api/active_model_serializers/labels/bug).
|
10
|
+
|
11
|
+
We are also actively working to identify tasks under the label [**Good for New Contributors**](https://github.com/rails-api/active_model_serializers/labels/Good%20for%20New%20Contributors). Some bugs are expressly not good for new contributors, so don't expect 100% overlap between the two.
|
12
|
+
|
13
|
+
If you want to work on new feature development, look for the label [**Feature**](https://github.com/rails-api/active_model_serializers/labels/Feature).
|
14
|
+
|
15
|
+
We are also encouraging comments to substantial changes (larger than bugfixes and simple features) under an "RFC" (Request for Comments) process before we start active development. Look for the [**RFC**](https://github.com/rails-api/active_model_serializers/labels/RFC) label.
|
16
|
+
|
17
|
+
## Issue Labeling
|
18
|
+
|
19
|
+
AMS uses a subset of [StandardIssueLabels](https://github.com/wagenet/StandardIssueLabels) for Github Issues. You can [see our labels here](https://github.com/rails-api/active_model_serializers/labels).
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it ( https://github.com/rails-api/active_model_serializers/fork )
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Write tests for your feature, or regression tests highlighting a bug
|
26
|
+
4. Write the feature itself, or fix your bug
|
27
|
+
5. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
6. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
7. Create a new Pull Request
|
30
|
+
|
31
|
+
Remember to squash your commits and rebase off `master`.
|
data/Gemfile
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify gem dependencies in active_model_serializers.gemspec
|
3
|
+
# Specify your gem's dependencies in active_model_serializers.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem "minitest"
|
7
|
+
|
8
|
+
version = ENV["RAILS_VERSION"] || "4.2"
|
9
|
+
|
10
|
+
if version == "master"
|
11
|
+
gem "rails", github: "rails/rails"
|
12
|
+
|
13
|
+
# ugh https://github.com/rails/rails/issues/16063#issuecomment-48090125
|
14
|
+
gem "arel", github: "rails/arel"
|
15
|
+
else
|
16
|
+
gem "rails", "~> #{version}.0"
|
17
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2014 Steve Klabnik
|
2
|
+
|
3
|
+
MIT License
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
6
|
a copy of this software and associated documentation files (the
|
@@ -18,4 +20,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|