├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CHANGELOG-0-08.md ├── CHANGELOG-0-09.md ├── CHANGELOG-0-10.md ├── CHANGELOG-prehistory.md ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── MIT-LICENSE ├── README.md ├── Rakefile ├── active_model_serializers.gemspec ├── appveyor.yml └── docs └── rfcs └── template.md /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Expected behavior vs actual behavior 2 | 3 | 4 | 5 | #### Steps to reproduce 6 | *(e.g., detailed walkthrough, runnable script, example application)* 7 | 8 | 9 | 10 | #### Environment 11 | 12 | ActiveModelSerializers Version *(commit ref if not on tag)*: 13 | 14 | Output of `ruby -e "puts RUBY_DESCRIPTION"`: 15 | 16 | OS Type & Version: 17 | 18 | Integrated application and version *(e.g., Rails, Grape, etc)*: 19 | 20 | 21 | #### Backtrace 22 | *(e.g., provide any applicable backtraces from your application)* 23 | 24 | 25 | 26 | #### Additonal helpful information 27 | *(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)* 28 | 29 | 30 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Purpose 2 | 3 | 4 | #### Changes 5 | 6 | 7 | #### Caveats 8 | 9 | 10 | #### Related GitHub issues 11 | 12 | 13 | #### Additional helpful information 14 | 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | Gemfile.local 8 | InstalledFiles 9 | _yardoc 10 | coverage 11 | doc/ 12 | lib/bundler/man 13 | pkg 14 | Vagrantfile 15 | .vagrant 16 | rdoc 17 | spec/reports 18 | test/tmp 19 | test/version_tmp 20 | tmp 21 | *.swp 22 | .ruby-version 23 | .ruby-gemset 24 | vendor/bundle 25 | tags 26 | 27 | # silly macs 28 | .DS_Store 29 | .DS_Store? 30 | ._* 31 | .Spotlight-V100 32 | .Trashes 33 | Icon? 34 | ehthumbs.db 35 | Thumbs.db 36 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | sudo: false 4 | 5 | cache: 6 | directories: 7 | - vendor/bundle 8 | 9 | script: 10 | - true 11 | -------------------------------------------------------------------------------- /CHANGELOG-0-08.md: -------------------------------------------------------------------------------- 1 | ## 0.08.x 2 | 3 | ### v0.8.3 (2014/12/10 14:45 +00:00) 4 | - [#753](https://github.com/rails-api/active_model_serializers/pull/753) Test against Ruby 2.2 on Travis CI (@tricknotes) 5 | - [#745](https://github.com/rails-api/active_model_serializers/pull/745) Missing a word (@jockee) 6 | 7 | ### v0.8.2 (2014/09/01 21:00 +00:00) 8 | - [#612](https://github.com/rails-api/active_model_serializers/pull/612) Feature/adapter (@bolshakov) 9 | * adds adapters pattern 10 | - [#615](https://github.com/rails-api/active_model_serializers/pull/615) Rails does not support const_defined? in development mode (@tpitale) 11 | - [#613](https://github.com/rails-api/active_model_serializers/pull/613) README: typo fix on attributes (@spk) 12 | - [#614](https://github.com/rails-api/active_model_serializers/pull/614) Fix rails 4.0.x build. (@arthurnn) 13 | - [#610](https://github.com/rails-api/active_model_serializers/pull/610) ArraySerializer (@bolshakov) 14 | - [#607](https://github.com/rails-api/active_model_serializers/pull/607) ruby syntax highlights (@zigomir) 15 | - [#602](https://github.com/rails-api/active_model_serializers/pull/602) Add DSL for associations (@JordanFaust) 16 | 17 | ### 0.8.1 (May 6, 2013) 18 | 19 | * Fix bug whereby a serializer using 'options' would blow up. 20 | 21 | ### 0.8.0 (May 5, 2013) 22 | 23 | * Attributes can now have optional types. 24 | 25 | * A new DefaultSerializer ensures that POROs behave the same way as ActiveModels. 26 | 27 | * If you wish to override ActiveRecord::Base#to_Json, you can now require 28 | 'active_record/serializer_override'. We don't recommend you do this, but 29 | many users do, so we've left it optional. 30 | 31 | * Fixed a bug where ActionController wouldn't always have MimeResponds. 32 | 33 | * An optinal caching feature allows you to cache JSON & hashes that AMS uses. 34 | Adding 'cached true' to your Serializers will turn on this cache. 35 | 36 | * URL helpers used inside of Engines now work properly. 37 | 38 | * Serializers now can filter attributes with `only` and `except`: 39 | 40 | ``` 41 | UserSerializer.new(user, only: [:first_name, :last_name]) 42 | UserSerializer.new(user, except: :first_name) 43 | ``` 44 | 45 | * Basic Mongoid support. We now include our mixins in the right place. 46 | 47 | * On Ruby 1.8, we now generate an `id` method that properly serializes `id` 48 | columns. See issue #127 for more. 49 | 50 | * Add an alias for `scope` method to be the name of the context. By default 51 | this is `current_user`. The name is automatically set when using 52 | `serialization_scope` in the controller. 53 | 54 | * Pass through serialization options (such as `:include`) when a model 55 | has no serializer defined. 56 | 57 | ## [0.7.0 (March 6, 2013)](https://github.com/rails-api/active_model_serializers/commit/fabdc621ff97fbeca317f6301973dd4564b9e695) 58 | 59 | * ```embed_key``` option to allow embedding by attributes other than IDs 60 | * Fix rendering nil with custom serializer 61 | * Fix global ```self.root = false``` 62 | * Add support for specifying the serializer for an association as a String 63 | * Able to specify keys on the attributes method 64 | * Serializer Reloading via ActiveSupport::DescendantsTracker 65 | * Reduce double map to once; Fixes datamapper eager loading. 66 | 67 | ## 0.6.0 (October 22, 2012) 68 | 69 | * Serialize sets properly 70 | * Add root option to ArraySerializer 71 | * Support polymorphic associations 72 | * Support :each_serializer in ArraySerializer 73 | * Add `scope` method to easily access the scope in the serializer 74 | * Fix regression with Rails 3.2.6; add Rails 4 support 75 | * Allow serialization_scope to be disabled with serialization_scope nil 76 | * Array serializer should support pure ruby objects besides serializers 77 | 78 | ## 0.05.x 79 | 80 | ### [0.5.2 (June 5, 2012)](https://github.com/rails-api/active_model_serializers/commit/615afd125c260432d456dc8be845867cf87ea118#diff-0c5c12f311d3b54734fff06069efd2ac) 81 | 82 | ### [0.5.1 (May 23, 2012)](https://github.com/rails-api/active_model_serializers/commit/00194ec0e41831802fcbf893a34c0bb0853ebe14#diff-0c5c12f311d3b54734fff06069efd2ac) 83 | 84 | ### [0.5.0 (May 16, 2012)](https://github.com/rails-api/active_model_serializers/commit/33d4842dcd35c7167b0b33fc0abcf00fb2c92286) 85 | 86 | * First tagged version 87 | * Changes generators to always generate an ApplicationSerializer 88 | 89 | ## [0.1.0 (December 21, 2011)](https://github.com/rails-api/active_model_serializers/commit/1e0c9ef93b96c640381575dcd30be07ac946818b) 90 | 91 | ## First Commit as [Rails Serializers 0.0.1](https://github.com/rails-api/active_model_serializers/commit/d72b66d4c5355b0ff0a75a04895fcc4ea5b0c65e) 92 | (December 1, 2011). 93 | -------------------------------------------------------------------------------- /CHANGELOG-0-09.md: -------------------------------------------------------------------------------- 1 | ## 0.09.x 2 | 3 | ### v0.9.3 (2015/01/21 20:29 +00:00) 4 | 5 | Features: 6 | - [#774](https://github.com/rails-api/active_model_serializers/pull/774) Fix nested include attributes (@nhocki) 7 | - [#771](https://github.com/rails-api/active_model_serializers/pull/771) Make linked resource type names consistent with root names (@sweatypitts) 8 | - [#696](https://github.com/rails-api/active_model_serializers/pull/696) Explicitly set serializer for associations (@ggordon) 9 | - [#700](https://github.com/rails-api/active_model_serializers/pull/700) sparse fieldsets (@arenoir) 10 | - [#768](https://github.com/rails-api/active_model_serializers/pull/768) Adds support for `meta` and `meta_key` attribute (@kurko) 11 | 12 | ### v0.9.1 (2014/12/04 11:54 +00:00) 13 | - [#707](https://github.com/rails-api/active_model_serializers/pull/707) A Friendly Note on Which AMS Version to Use (@jherdman) 14 | - [#730](https://github.com/rails-api/active_model_serializers/pull/730) Fixes nested has_many links in JSONAPI (@kurko) 15 | - [#718](https://github.com/rails-api/active_model_serializers/pull/718) Allow overriding the adapter with render option (@ggordon) 16 | - [#720](https://github.com/rails-api/active_model_serializers/pull/720) Rename attribute with :key (0.8.x compatibility) (@ggordon) 17 | - [#728](https://github.com/rails-api/active_model_serializers/pull/728) Use type as key for linked resources (@kurko) 18 | - [#729](https://github.com/rails-api/active_model_serializers/pull/729) Use the new beta build env on Travis (@joshk) 19 | - [#703](https://github.com/rails-api/active_model_serializers/pull/703) Support serializer and each_serializer options in renderer (@ggordon, @mieko) 20 | - [#727](https://github.com/rails-api/active_model_serializers/pull/727) Includes links inside of linked resources (@kurko) 21 | - [#726](https://github.com/rails-api/active_model_serializers/pull/726) Bugfix: include nested has_many associations (@kurko) 22 | - [#722](https://github.com/rails-api/active_model_serializers/pull/722) Fix infinite recursion (@ggordon) 23 | - [#1](https://github.com/rails-api/active_model_serializers/pull/1) Allow for the implicit use of ArraySerializer when :each_serializer is specified (@mieko) 24 | - [#692](https://github.com/rails-api/active_model_serializers/pull/692) Include 'linked' member for json-api collections (@ggordon) 25 | - [#714](https://github.com/rails-api/active_model_serializers/pull/714) Define as_json instead of to_json (@guilleiguaran) 26 | - [#710](https://github.com/rails-api/active_model_serializers/pull/710) JSON-API: Don't include linked section if associations are empty (@guilleiguaran) 27 | - [#711](https://github.com/rails-api/active_model_serializers/pull/711) Fixes rbx gems bundling on TravisCI (@kurko) 28 | - [#709](https://github.com/rails-api/active_model_serializers/pull/709) Add type key when association name is different than object type (@guilleiguaran) 29 | - [#708](https://github.com/rails-api/active_model_serializers/pull/708) Handle correctly null associations (@guilleiguaran) 30 | - [#691](https://github.com/rails-api/active_model_serializers/pull/691) Fix embed option for associations (@jacob-s-son) 31 | - [#689](https://github.com/rails-api/active_model_serializers/pull/689) Fix support for custom root in JSON-API adapter (@guilleiguaran) 32 | - [#685](https://github.com/rails-api/active_model_serializers/pull/685) Serialize ids as strings in JSON-API adapter (@guilleiguaran) 33 | - [#684](https://github.com/rails-api/active_model_serializers/pull/684) Refactor adapters to implement support for array serialization (@guilleiguaran) 34 | - [#682](https://github.com/rails-api/active_model_serializers/pull/682) Include root by default in JSON-API serializers (@guilleiguaran) 35 | - [#625](https://github.com/rails-api/active_model_serializers/pull/625) Add DSL for urls (@JordanFaust) 36 | - [#677](https://github.com/rails-api/active_model_serializers/pull/677) Add support for embed: :ids option for in associations (@guilleiguaran) 37 | - [#681](https://github.com/rails-api/active_model_serializers/pull/681) Check superclasses for Serializers (@quainjn) 38 | - [#680](https://github.com/rails-api/active_model_serializers/pull/680) Add support for root keys (@NullVoxPopuli) 39 | - [#675](https://github.com/rails-api/active_model_serializers/pull/675) Support Rails 4.2.0 (@tricknotes) 40 | - [#667](https://github.com/rails-api/active_model_serializers/pull/667) Require only activemodel instead of full rails (@guilleiguaran) 41 | - [#653](https://github.com/rails-api/active_model_serializers/pull/653) Add "_test" suffix to JsonApi::HasManyTest filename. (@alexgenco) 42 | - [#631](https://github.com/rails-api/active_model_serializers/pull/631) Update build badge URL (@craiglittle) 43 | 44 | ### 0.9.0.alpha1 - January 7, 2014 45 | 46 | ### 0.9.0.pre 47 | 48 | * The following methods were removed 49 | - Model#active\_model\_serializer 50 | - Serializer#include! 51 | - Serializer#include? 52 | - Serializer#attr\_disabled= 53 | - Serializer#cache 54 | - Serializer#perform\_caching 55 | - Serializer#schema (needs more discussion) 56 | - Serializer#attribute 57 | - Serializer#include\_#{name}? (filter method added) 58 | - Serializer#attributes (took a hash) 59 | 60 | * The following things were added 61 | - Serializer#filter method 62 | - CONFIG object 63 | 64 | * Remove support for ruby 1.8 versions. 65 | 66 | * Require rails >= 3.2. 67 | 68 | * Serializers for associations are being looked up in a parent serializer's namespace first. Same with controllers' namespaces. 69 | 70 | * Added a "prefix" option in case you want to use a different version of serializer. 71 | 72 | * Serializers default namespace can be set in `default_serializer_options` and inherited by associations. 73 | 74 | * [Beginning of rewrite: c65d387705ec534db171712671ba7fcda4f49f68](https://github.com/rails-api/active_model_serializers/commit/c65d387705ec534db171712671ba7fcda4f49f68) 75 | -------------------------------------------------------------------------------- /CHANGELOG-0-10.md: -------------------------------------------------------------------------------- 1 | ## 0.10.x 2 | 3 | ### [0-10-stable (unreleased)](https://github.com/rails-api/active_model_serializers/compare/v0.10.6...0-10-stable) 4 | 5 | Breaking changes: 6 | 7 | Features: 8 | 9 | Fixes: 10 | 11 | Misc: 12 | 13 | ### [v0.10.6 (2017-05-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.5...v0.10.6) 14 | 15 | Fixes: 16 | 17 | - [#1857](https://github.com/rails-api/active_model_serializers/pull/1857) JSON:API does not load belongs_to relation to get identifier id. (@bf4) 18 | - [#2119](https://github.com/rails-api/active_model_serializers/pull/2119) JSON:API returns null resource object identifier when 'id' is null. (@bf4) 19 | - [#2093](https://github.com/rails-api/active_model_serializers/pull/2093) undef problematic Serializer methods: display, select. (@bf4) 20 | 21 | Misc: 22 | 23 | - [#2104](https://github.com/rails-api/active_model_serializers/pull/2104) Documentation for serializers and rendering. (@cassidycodes) 24 | - [#2081](https://github.com/rails-api/active_model_serializers/pull/2081) Documentation for `include` option in adapters. (@charlie-wasp) 25 | - [#2120](https://github.com/rails-api/active_model_serializers/pull/2120) Documentation for association options: foreign_key, type, class_name, namespace. (@bf4) 26 | 27 | ### [v0.10.5 (2017-03-07)](https://github.com/rails-api/active_model_serializers/compare/v0.10.4...v0.10.5) 28 | 29 | Breaking changes: 30 | 31 | Features: 32 | 33 | - [#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) 34 | - [#2057](https://github.com/rails-api/active_model_serializers/pull/2057) 35 | Update version constraint for jsonapi-renderer to `['>= 0.1.1.beta1', '< 0.2']` 36 | (@jaredbeck) 37 | 38 | Fixes: 39 | 40 | - [#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) 41 | 42 | Misc: 43 | 44 | - [#2055](https://github.com/rails-api/active_model_serializers/pull/2055) 45 | Replace deprecated dependency jsonapi with jsonapi-renderer. (@jaredbeck) 46 | - [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) Make test attributes explicit. Tests have Model#associations. (@bf4) 47 | - [#1981](https://github.com/rails-api/active_model_serializers/pull/1981) Fix relationship link documentation. (@groyoh) 48 | - [#2035](https://github.com/rails-api/active_model_serializers/pull/2035) Document how to disable the logger. (@MSathieu) 49 | - [#2039](https://github.com/rails-api/active_model_serializers/pull/2039) Documentation fixes. (@biow0lf) 50 | 51 | ### [v0.10.4 (2017-01-06)](https://github.com/rails-api/active_model_serializers/compare/v0.10.3...v0.10.4) 52 | 53 | Misc: 54 | 55 | - [#2005](https://github.com/rails-api/active_model_serializers/pull/2005) Update jsonapi runtime dependency to 0.1.1.beta6, support Ruby 2.4. (@kofronpi) 56 | - [#1993](https://github.com/rails-api/active_model_serializers/pull/1993) Swap out KeyTransform for CaseTransform gem for the possibility of native extension use. (@NullVoxPopuli) 57 | 58 | ### [v0.10.3 (2016-11-21)](https://github.com/rails-api/active_model_serializers/compare/v0.10.2...v0.10.3) 59 | 60 | Fixes: 61 | 62 | - [#1973](https://github.com/rails-api/active_model_serializers/pull/1973) Fix namespace lookup for collections and has_many relationships (@groyoh) 63 | - [#1887](https://github.com/rails-api/active_model_serializers/pull/1887) Make the comment reflect what the function does (@johnnymo87) 64 | - [#1890](https://github.com/rails-api/active_model_serializers/issues/1890) Ensure generator inherits from ApplicationSerializer when available (@richmolj) 65 | - [#1922](https://github.com/rails-api/active_model_serializers/pull/1922) Make railtie an optional dependency in runtime (@ggpasqualino) 66 | - [#1930](https://github.com/rails-api/active_model_serializers/pull/1930) Ensure valid jsonapi when relationship has no links or data (@richmolj) 67 | 68 | Features: 69 | 70 | - [#1757](https://github.com/rails-api/active_model_serializers/pull/1757) Make serializer lookup chain configurable. (@NullVoxPopuli) 71 | - [#1968](https://github.com/rails-api/active_model_serializers/pull/1968) (@NullVoxPopuli) 72 | - Add controller namespace to default controller lookup 73 | - Provide a `namespace` render option 74 | - document how set the namespace in the controller for implicit lookup. 75 | - [#1791](https://github.com/rails-api/active_model_serializers/pull/1791) (@bf4, @youroff, @NullVoxPopuli) 76 | - Added `jsonapi_namespace_separator` config option. 77 | - [#1889](https://github.com/rails-api/active_model_serializers/pull/1889) Support key transformation for Attributes adapter (@iancanderson, @danbee) 78 | - [#1917](https://github.com/rails-api/active_model_serializers/pull/1917) Add `jsonapi_pagination_links_enabled` configuration option (@richmolj) 79 | - [#1797](https://github.com/rails-api/active_model_serializers/pull/1797) Only include 'relationships' when sideloading (@richmolj) 80 | 81 | Fixes: 82 | 83 | - [#1833](https://github.com/rails-api/active_model_serializers/pull/1833) Remove relationship links if they are null (@groyoh) 84 | - [#1881](https://github.com/rails-api/active_model_serializers/pull/1881) ActiveModelSerializers::Model correctly works with string keys (@yevhene) 85 | 86 | Misc: 87 | - [#1767](https://github.com/rails-api/active_model_serializers/pull/1767) Replace raising/rescuing `CollectionSerializer::NoSerializerError`, 88 | throw/catch `:no_serializer`. (@bf4) 89 | - [#1839](https://github.com/rails-api/active_model_serializers/pull/1839) `fields` tests demonstrating usage for both attributes and relationships. (@NullVoxPopuli) 90 | - [#1812](https://github.com/rails-api/active_model_serializers/pull/1812) add a code of conduct (@corainchicago) 91 | 92 | - [#1878](https://github.com/rails-api/active_model_serializers/pull/1878) Cache key generation for serializers now uses `ActiveSupport::Cache.expand_cache_key` instead of `Array#join` by default and is also overridable. This change should be backward-compatible. (@markiz) 93 | 94 | - [#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@cassidycodes) 95 | - [#1909](https://github.com/rails-api/active_model_serializers/pull/1909) Add documentation for relationship links. (@vasilakisfil, @NullVoxPopuli) 96 | - [#1959](https://github.com/rails-api/active_model_serializers/pull/1959) Add documentation for root. (@shunsuke227ono) 97 | - [#1967](https://github.com/rails-api/active_model_serializers/pull/1967) Improve type method documentation. (@yukideluxe) 98 | 99 | ### [v0.10.2 (2016-07-05)](https://github.com/rails-api/active_model_serializers/compare/v0.10.1...v0.10.2) 100 | 101 | Fixes: 102 | - [#1814](https://github.com/rails-api/active_model_serializers/pull/1814) Ensuring read_multi works with fragment cache 103 | - [#1848](https://github.com/rails-api/active_model_serializers/pull/1848) Redefine associations on inherited serializers. (@EhsanYousefi) 104 | 105 | Misc: 106 | - [#1808](https://github.com/rails-api/active_model_serializers/pull/1808) Adds documentation for `fields` option. (@luizkowalski) 107 | 108 | ### [v0.10.1 (2016-06-16)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0...v0.10.1) 109 | 110 | Features: 111 | - [#1668](https://github.com/rails-api/active_model_serializers/pull/1668) Exclude nil and empty links. (@sigmike) 112 | - [#1426](https://github.com/rails-api/active_model_serializers/pull/1426) Add ActiveModelSerializers.config.default_includes (@empact) 113 | 114 | Fixes: 115 | - [#1754](https://github.com/rails-api/active_model_serializers/pull/1754) Fixes #1759, Grape integration, improves serialization_context 116 | missing error message on pagination. Document overriding CollectionSerializer#paginated?. (@bf4) 117 | Moved serialization_context creation to Grape formatter, so resource serialization works without explicit calls to the `render` helper method. 118 | Added Grape collection tests. (@onomated) 119 | - [#1287](https://github.com/rails-api/active_model_serializers/pull/1287) Pass `fields` options from adapter to serializer. (@vasilakisfil) 120 | - [#1710](https://github.com/rails-api/active_model_serializers/pull/1710) Prevent association loading when `include_data` option 121 | is set to `false`. (@groyoh) 122 | - [#1747](https://github.com/rails-api/active_model_serializers/pull/1747) Improve jsonapi mime type registration for Rails 5 (@remear) 123 | 124 | Misc: 125 | - [#1734](https://github.com/rails-api/active_model_serializers/pull/1734) Adds documentation for conditional attribute (@lambda2) 126 | - [#1685](https://github.com/rails-api/active_model_serializers/pull/1685) Replace `IncludeTree` with `IncludeDirective` from the jsonapi gem. 127 | 128 | ### [v0.10.0 (2016-05-17)](https://github.com/rails-api/active_model_serializers/compare/4a2d9853ba7...v0.10.0) 129 | 130 | Breaking changes: 131 | - [#1662](https://github.com/rails-api/active_model_serializers/pull/1662) Drop support for Rails 4.0 and Ruby 2.0.0. (@remear) 132 | 133 | Features: 134 | - [#1677](https://github.com/rails-api/active_model_serializers/pull/1677) Add `assert_schema`, `assert_request_schema`, `assert_request_response_schema`. (@bf4) 135 | - [#1697](https://github.com/rails-api/active_model_serializers/pull/1697) Include actual exception message with custom exceptions; 136 | `Test::Schema` exceptions are now `Minitest::Assertion`s. (@bf4) 137 | - [#1699](https://github.com/rails-api/active_model_serializers/pull/1699) String/Lambda support for conditional attributes/associations (@mtsmfm) 138 | - [#1687](https://github.com/rails-api/active_model_serializers/pull/1687) Only calculate `_cache_digest` (in `cache_key`) when `skip_digest` is false. (@bf4) 139 | - [#1647](https://github.com/rails-api/active_model_serializers/pull/1647) Restrict usage of `serializable_hash` options 140 | to the ActiveModel::Serialization and ActiveModel::Serializers::JSON interface. (@bf4) 141 | 142 | Fixes: 143 | - [#1700](https://github.com/rails-api/active_model_serializers/pull/1700) Support pagination link for Kaminari when no data is returned. (@iamnader) 144 | - [#1726](https://github.com/rails-api/active_model_serializers/pull/1726) Adds polymorphic option to association definition which includes association type/nesting in serializer (@cgmckeever) 145 | 146 | Misc: 147 | - [#1673](https://github.com/rails-api/active_model_serializers/pull/1673) Adds "How to" guide on using AMS with POROs (@DrSayre) 148 | - [#1730](https://github.com/rails-api/active_model_serializers/pull/1730) Adds documentation for overriding default serializer based on conditions (@groyoh/@cgmckeever) 149 | 150 | ### [v0.10.0.rc5 (2016-04-04)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0.rc4...v0.10.0.rc5) 151 | 152 | Breaking changes: 153 | 154 | - [#1645](https://github.com/rails-api/active_model_serializers/pull/1645) Changed :dashed key transform to :dash. (@remear) 155 | - [#1574](https://github.com/rails-api/active_model_serializers/pull/1574) Default key case for the JsonApi adapter changed to dashed. (@remear) 156 | 157 | Features: 158 | - [#1645](https://github.com/rails-api/active_model_serializers/pull/1645) Transform keys referenced in values. (@remear) 159 | - [#1650](https://github.com/rails-api/active_model_serializers/pull/1650) Fix serialization scope options `scope`, `scope_name` 160 | take precedence over `serialization_scope` in the controller. 161 | Fix tests that required tearing down dynamic methods. (@bf4) 162 | - [#1644](https://github.com/rails-api/active_model_serializers/pull/1644) Include adapter name in cache key so 163 | that the same serializer can be cached per adapter. (@bf4 via #1346 by @kevintyll) 164 | - [#1642](https://github.com/rails-api/active_model_serializers/pull/1642) Prefer object.cache_key over the generated 165 | cache key. (@bf4 via #1346 by @kevintyll) 166 | - [#1637](https://github.com/rails-api/active_model_serializers/pull/1637) Make references to 'ActionController::Base.cache_store' explicit 167 | in order to avoid issues when application controllers inherit from 'ActionController::API'. (@ncuesta) 168 | - [#1633](https://github.com/rails-api/active_model_serializers/pull/1633) Yield 'serializer' to serializer association blocks. (@bf4) 169 | - [#1616](https://github.com/rails-api/active_model_serializers/pull/1616) SerializableResource handles no serializer like controller. (@bf4) 170 | - [#1618](https://github.com/rails-api/active_model_serializers/issues/1618) Get collection root key for 171 | empty collection from explicit serializer option, when possible. (@bf4) 172 | - [#1574](https://github.com/rails-api/active_model_serializers/pull/1574) Provide key translation. (@remear) 173 | - [#1494](https://github.com/rails-api/active_model_serializers/pull/1494) Make serializers serializalbe 174 | (using the Attributes adapter by default). (@bf4) 175 | - [#1550](https://github.com/rails-api/active_model_serializers/pull/1550) Add 176 | Rails url_helpers to `SerializationContext` for use in links. (@remear, @bf4) 177 | - [#1004](https://github.com/rails-api/active_model_serializers/pull/1004) JSON API errors object implementation. 178 | - Only implements `detail` and `source` as derived from `ActiveModel::Error` 179 | - Provides checklist of remaining questions and remaining parts of the spec. 180 | - [#1515](https://github.com/rails-api/active_model_serializers/pull/1515) Adds support for symbols to the 181 | `ActiveModel::Serializer.type` method. (@groyoh) 182 | - [#1504](https://github.com/rails-api/active_model_serializers/pull/1504) Adds the changes missing from #1454 183 | and add more tests for resource identifier and relationship objects. Fix association block with link 184 | returning `data: nil`.(@groyoh) 185 | - [#1372](https://github.com/rails-api/active_model_serializers/pull/1372) Support 186 | cache_store.read_multi. (@LcpMarvel) 187 | - [#1018](https://github.com/rails-api/active_model_serializers/pull/1018) Add more tests and docs for top-level links. (@leandrocp) 188 | - [#1454](https://github.com/rails-api/active_model_serializers/pull/1454) Add support for 189 | relationship-level links and meta attributes. (@beauby) 190 | - [#1340](https://github.com/rails-api/active_model_serializers/pull/1340) Add support for resource-level meta. (@beauby) 191 | 192 | Fixes: 193 | - [#1657](https://github.com/rails-api/active_model_serializers/pull/1657) Add missing missing require "active_support/json". (@andreaseger) 194 | - [#1661](https://github.com/rails-api/active_model_serializers/pull/1661) Fixes `read_attribute_for_serialization` not 195 | seeing methods defined in serialization superclass (#1653, #1658, #1660), introduced in #1650. (@bf4) 196 | - [#1651](https://github.com/rails-api/active_model_serializers/pull/1651) Fix deserialization of nil relationships. (@NullVoxPopuli) 197 | - [#1480](https://github.com/rails-api/active_model_serializers/pull/1480) Fix setting of cache_store from Rails configuration. (@bf4) 198 | Fix unintentional mutating of value in memory cache store. (@groyoh) 199 | - [#1622](https://github.com/rails-api/active_model_serializers/pull/1622) Fragment cache changed from per-record to per-serializer. 200 | Now, two serializers that use the same model may be separately cached. (@lserman) 201 | - [#1478](https://github.com/rails-api/active_model_serializers/pull/1478) Cache store will now be correctly set when serializers are 202 | loaded *before* Rails initializes. (@bf4) 203 | - [#1570](https://github.com/rails-api/active_model_serializers/pull/1570) Fixed pagination issue with last page size. (@bmorrall) 204 | - [#1516](https://github.com/rails-api/active_model_serializers/pull/1516) No longer return a nil href when only 205 | adding meta to a relationship link. (@groyoh) 206 | - [#1458](https://github.com/rails-api/active_model_serializers/pull/1458) Preserve the serializer 207 | type when fragment caching. (@bdmac) 208 | - [#1477](https://github.com/rails-api/active_model_serializers/pull/1477) Fix `fragment_cached?` 209 | method to check if caching. (@bdmac) 210 | - [#1501](https://github.com/rails-api/active_model_serializers/pull/1501) Adds tests for SerializableResource::use_adapter?,doc typos (@domitian) 211 | - [#1488](https://github.com/rails-api/active_model_serializers/pull/1488) Require ActiveSupport's string inflections (@nate00) 212 | 213 | Misc: 214 | - [#1608](https://github.com/rails-api/active_model_serializers/pull/1608) Move SerializableResource to ActiveModelSerializers (@groyoh) 215 | - [#1602](https://github.com/rails-api/active_model_serializers/pull/1602) Add output examples to Adapters docs (@remear) 216 | - [#1557](https://github.com/rails-api/active_model_serializers/pull/1557) Update docs regarding overriding the root key (@Jwan622) 217 | - [#1471](https://github.com/rails-api/active_model_serializers/pull/1471) [Cleanup] Serializer caching is its own concern. (@bf4) 218 | - [#1482](https://github.com/rails-api/active_model_serializers/pull/1482) Document JSON API implementation defs and progress in class. (@bf4) 219 | - [#1551](https://github.com/rails-api/active_model_serializers/pull/1551) Added codebeat badge (@korzonek) 220 | - [#1527](https://github.com/rails-api/active_model_serializers/pull/1527) Refactor fragment cache class. (@groyoh) 221 | - [#1560](https://github.com/rails-api/active_model_serializers/pull/1560) Update rubocop and address its warnings. (@bf4 @groyoh) 222 | - [#1545](https://github.com/rails-api/active_model_serializers/pull/1545) Document how to pass arbitrary options to the 223 | serializer (@CodedBeardedSignedTaylor) 224 | - [#1496](https://github.com/rails-api/active_model_serializers/pull/1496) Run all branches against JRuby on CI (@nadavshatz) 225 | - [#1559](https://github.com/rails-api/active_model_serializers/pull/1559) Add a deprecation DSL. (@bf4 @groyoh) 226 | - [#1543](https://github.com/rails-api/active_model_serializers/pull/1543) Add the changes missing from #1535. (@groyoh) 227 | - [#1535](https://github.com/rails-api/active_model_serializers/pull/1535) Move the adapter and adapter folder to 228 | active_model_serializers folder and changes the module namespace. (@domitian @bf4) 229 | - [#1497](https://github.com/rails-api/active_model_serializers/pull/1497) Add JRuby-9000 to appveyor.yml(@corainchicago) 230 | - [#1420](https://github.com/rails-api/active_model_serializers/pull/1420) Adds tests and documentation for polymorphism(@marcgarreau) 231 | 232 | 233 | ### [v0.10.0.rc4 (2016-01-27)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0.rc3...v0.10.0.rc4) 234 | Breaking changes: 235 | 236 | - [#1360](https://github.com/rails-api/active_model_serializers/pull/1360) 237 | [#1369](https://github.com/rails-api/active_model_serializers/pull/1369) Drop support for Ruby 1.9.3 (@karaAJC, @maurogeorge) 238 | - [#1131](https://github.com/rails-api/active_model_serializers/pull/1131) Remove Serializer#root_name (@beauby) 239 | - [#1138](https://github.com/rails-api/active_model_serializers/pull/1138) Introduce Adapter::Base (@bf4) 240 | * Adapters now inherit Adapter::Base. 'Adapter' is now a module, no longer a class. 241 | * using a class as a namespace that you also inherit from is complicated and circular at times i.e. 242 | buggy (see https://github.com/rails-api/active_model_serializers/pull/1177) 243 | * The class methods on Adapter aren't necessarily related to the instance methods, they're more 244 | Adapter functions. 245 | * named `Base` because it's a Rails-ism. 246 | * It helps to isolate and highlight what the Adapter interface actually is. 247 | - [#1418](https://github.com/rails-api/active_model_serializers/pull/1418) 248 | serialized collections now use the root option as is; now, only the 249 | root derived from the serializer or object is always pluralized. 250 | 251 | Features: 252 | 253 | - [#1406](https://github.com/rails-api/active_model_serializers/pull/1406) Allow for custom dynamic values in JSON API links (@beauby) 254 | - [#1270](https://github.com/rails-api/active_model_serializers/pull/1270) Adds `assert_response_schema` test helper (@maurogeorge) 255 | - [#1099](https://github.com/rails-api/active_model_serializers/pull/1099) Adds `assert_serializer` test helper (@maurogeorge) 256 | - [#1403](https://github.com/rails-api/active_model_serializers/pull/1403) Add support for if/unless on attributes/associations (@beauby) 257 | - [#1248](https://github.com/rails-api/active_model_serializers/pull/1248) Experimental: Add support for JSON API deserialization (@beauby) 258 | - [#1378](https://github.com/rails-api/active_model_serializers/pull/1378) Change association blocks 259 | to be evaluated in *serializer* scope, rather than *association* scope. (@bf4) 260 | * Syntax changes from e.g. 261 | `has_many :titles do customers.pluck(:title) end` (in #1356) to 262 | `has_many :titles do object.customers.pluck(:title) end` 263 | - [#1356](https://github.com/rails-api/active_model_serializers/pull/1356) Add inline syntax for 264 | attributes and associations (@bf4 @beauby @noahsilas) 265 | * Allows defining attributes so that they don't conflict with existing methods. e.g. `attribute 266 | :title do 'Mr. Topum Hat' end` 267 | * Allows defining associations so that they don't conflict with existing methods. e.g. `has_many 268 | :titles do customers.pluck(:title) end` 269 | * Allows dynamic associations, as compared to compare to using 270 | [`virtual_value`](https://github.com/rails-api/active_model_serializers/pull/1356#discussion_r47146466). 271 | e.g. `has_many :reviews, virtual_value: [{ id: 1 }, { id: 2 }]` 272 | * Removes dynamically defined methods on the serializer 273 | - [#1336](https://github.com/rails-api/active_model_serializers/pull/1336) Added support for Grape >= 0.13, < 1.0 (@johnhamelink) 274 | - [#1322](https://github.com/rails-api/active_model_serializers/pull/1322) Instrumenting rendering of resources (@bf4, @maurogeorge) 275 | - [#1291](https://github.com/rails-api/active_model_serializers/pull/1291) Add logging (@maurogeorge) 276 | - [#1272](https://github.com/rails-api/active_model_serializers/pull/1272) Add PORO serializable base class: ActiveModelSerializers::Model (@bf4) 277 | - [#1255](https://github.com/rails-api/active_model_serializers/pull/1255) Make more class attributes inheritable (@bf4) 278 | - [#1249](https://github.com/rails-api/active_model_serializers/pull/1249) Inheritance of serializer inheriting the cache configuration(@Rodrigora) 279 | - [#1247](https://github.com/rails-api/active_model_serializers/pull/1247) Add support for toplevel JSON API links (@beauby) 280 | - [#1246](https://github.com/rails-api/active_model_serializers/pull/1246) Add support for resource-level JSON API links (@beauby) 281 | - [#1225](https://github.com/rails-api/active_model_serializers/pull/1225) Better serializer lookup, use nested serializer when it exists (@beauby) 282 | - [#1213](https://github.com/rails-api/active_model_serializers/pull/1213) `type` directive for serializer to control type field with json-api adapter (@youroff) 283 | - [#1172](https://github.com/rails-api/active_model_serializers/pull/1172) Better serializer registration, get more than just the first module (@bf4) 284 | - [#1158](https://github.com/rails-api/active_model_serializers/pull/1158) Add support for wildcards in `include` option (@beauby) 285 | - [#1127](https://github.com/rails-api/active_model_serializers/pull/1127) Add support for nested 286 | associations for JSON and Attributes adapters via the `include` option (@NullVoxPopuli, @beauby). 287 | - [#1050](https://github.com/rails-api/active_model_serializers/pull/1050) Add support for toplevel jsonapi member (@beauby, @bf4) 288 | - [#1251](https://github.com/rails-api/active_model_serializers/pull/1251) Rename ArraySerializer to 289 | CollectionSerializer for clarity, add ActiveModelSerializers.config.collection_serializer (@bf4) 290 | - [#1295](https://github.com/rails-api/active_model_serializers/pull/1295) Add config `serializer_lookup_enabled` that, 291 | when disabled, requires serializers to explicitly specified. (@trek) 292 | 293 | Fixes: 294 | 295 | - [#1352](https://github.com/rails-api/active_model_serializers/pull/1352) Fix generators; Isolate Rails-specifc code in Railties (@dgynn, @bf4) 296 | - [#1384](https://github.com/rails-api/active_model_serializers/pull/1384)Fix database state leaking across tests (@bf4) 297 | - [#1297](https://github.com/rails-api/active_model_serializers/pull/1297) Fix `fields` option to restrict relationships as well (@beauby) 298 | - [#1239](https://github.com/rails-api/active_model_serializers/pull/1239) Fix duplicates in JSON API compound documents (@beauby) 299 | - [#1214](https://github.com/rails-api/active_model_serializers/pull/1214) retrieve the key from the reflection options when building associations (@NullVoxPopuli, @hut8) 300 | - [#1358](https://github.com/rails-api/active_model_serializers/pull/1358) Handle serializer file paths with spaces (@rwstauner, @bf4) 301 | - [#1195](https://github.com/rails-api/active_model_serializers/pull/1195) Fix id override (@beauby) 302 | - [#1185](https://github.com/rails-api/active_model_serializers/pull/1185) Fix options passing in Json and Attributes adapters (@beauby) 303 | 304 | Misc: 305 | 306 | - [#1383](https://github.com/rails-api/active_model_serializers/pull/1383) Simplify reflections handling (@beauby) 307 | - [#1370](https://github.com/rails-api/active_model_serializers/pull/1370) Simplify attributes handling via a mixin (@beauby) 308 | - [#1301](https://github.com/rails-api/active_model_serializers/pull/1301) Mapping JSON API spec / schema to AMS (@bf4) 309 | - [#1271](https://github.com/rails-api/active_model_serializers/pull/1271) Handle no serializer source file to digest (@bf4) 310 | - [#1260](https://github.com/rails-api/active_model_serializers/pull/1260) Serialization and Cache Documentation (@bf4) 311 | - [#1259](https://github.com/rails-api/active_model_serializers/pull/1259) Add more info to CONTRIBUTING (@bf4) 312 | - [#1233](https://github.com/rails-api/active_model_serializers/pull/1233) Top-level meta and meta_key options no longer handled at serializer level (@beauby) 313 | - [#1232](https://github.com/rails-api/active_model_serializers/pull/1232) fields option no longer handled at serializer level (@beauby) 314 | - [#1220](https://github.com/rails-api/active_model_serializers/pull/1220) Remove empty rubocop.rake (@maurogeorge) 315 | - [#1178](https://github.com/rails-api/active_model_serializers/pull/1178) env CAPTURE_STDERR=false lets devs see hard failures (@bf4) 316 | - [#1177](https://github.com/rails-api/active_model_serializers/pull/1177) Remove Adapter autoloads in favor of require (@bf4) 317 | - [#1117](https://github.com/rails-api/active_model_serializers/pull/1117) FlattenJson adapter no longer inherits Json adapter, renamed to Attributes (@bf4) 318 | - [#1171](https://github.com/rails-api/active_model_serializers/pull/1171) add require statements to top of file (@shicholas) 319 | - [#1167](https://github.com/rails-api/active_model_serializers/pull/1167) Delegate Serializer.attributes to Serializer.attribute (@bf4) 320 | - [#1174](https://github.com/rails-api/active_model_serializers/pull/1174) Consistently refer to the 'JSON API' and the 'JsonApi' adapter (@bf4) 321 | - [#1173](https://github.com/rails-api/active_model_serializers/pull/1173) Comment private accessor warnings (@bf4) 322 | - [#1166](https://github.com/rails-api/active_model_serializers/pull/1166) Prefer methods over instance variables (@bf4) 323 | - [#1168](https://github.com/rails-api/active_model_serializers/pull/1168) Fix appveyor failure cache not being expired (@bf4) 324 | - [#1161](https://github.com/rails-api/active_model_serializers/pull/1161) Remove duplicate test helper (@bf4) 325 | - [#1360](https://github.com/rails-api/active_model_serializers/pull/1360) Update CI to test 2.2.2 -> 2.2.3 (@karaAJC) 326 | - [#1371](https://github.com/rails-api/active_model_serializers/pull/1371) Refactor, update, create documentation (@bf4) 327 | 328 | ### [v0.10.0.rc3 (2015-09-16)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0.rc2...v0.10.0.rc3) 329 | - [#1129](https://github.com/rails-api/active_model_serializers/pull/1129) Remove SerializableResource.serialize in favor of `.new` (@bf4) 330 | - [#1155](https://github.com/rails-api/active_model_serializers/pull/1155) Outside controller use tutorial (@CodedBeardedSignedTaylor) 331 | - [#1154](https://github.com/rails-api/active_model_serializers/pull/1154) Rubocop fixes for issues introduced by #1089 (@NullVoxPopuli) 332 | - [#1089](https://github.com/rails-api/active_model_serializers/pull/1089) Add ActiveModelSerializers.logger with default null device (@bf4) 333 | - [#1109](https://github.com/rails-api/active_model_serializers/pull/1109) Make better use of Minitest's lifecycle (@bf4) 334 | - [#1144](https://github.com/rails-api/active_model_serializers/pull/1144) Fix Markdown to adapters documentation (@bacarini) 335 | - [#1121](https://github.com/rails-api/active_model_serializers/pull/1121) Refactor `add_links` in JSONAPI adapter. (@beauby) 336 | - [#1150](https://github.com/rails-api/active_model_serializers/pull/1150) Remove legacy method accidentally reintroduced in #1017 (@beauby) 337 | - [#1149](https://github.com/rails-api/active_model_serializers/pull/1149) Update README with nested included association example. (@mattmueller) 338 | - [#1110](https://github.com/rails-api/active_model_serializers/pull/1110) Add lint tests for AR models (@beauby) 339 | - [#1131](https://github.com/rails-api/active_model_serializers/pull/1131) Extended format for JSONAPI `include` option (@beauby) 340 | * adds extended format for `include` option to JsonApi adapter 341 | - [#1142](https://github.com/rails-api/active_model_serializers/pull/1142) Updating wording on cache expiry in README (@leighhalliday) 342 | - [#1140](https://github.com/rails-api/active_model_serializers/pull/1140) Fix typo in fieldset exception (@lautis) 343 | - [#1132](https://github.com/rails-api/active_model_serializers/pull/1132) Get rid of unnecessary instance variables, and implied dependencies. (@beauby) 344 | - [#1139](https://github.com/rails-api/active_model_serializers/pull/1139) Documentation for serializing resources without render (@PericlesTheo) 345 | - [#1017](https://github.com/rails-api/active_model_serializers/pull/1017) Make Adapters registerable so they are not namespace-constrained (@bf4) 346 | - [#1120](https://github.com/rails-api/active_model_serializers/pull/1120) Add windows platform to loading sqlite3 (@Eric-Guo) 347 | - [#1123](https://github.com/rails-api/active_model_serializers/pull/1123) Remove url options (@bacarini) 348 | - [#1093](https://github.com/rails-api/active_model_serializers/pull/1093) Factor `with_adapter` + force cache clear before each test. (@beauby) 349 | - [#1095](https://github.com/rails-api/active_model_serializers/pull/1095) Add documentation about configuration options. (@beauby) 350 | - [#1069](https://github.com/rails-api/active_model_serializers/pull/1069) Add test coverage; account for no artifacts on CI (@bf4) 351 | - [#1103](https://github.com/rails-api/active_model_serializers/pull/1103) Move `id` and `json_api_type` methods from `Serializer` to `JsonApi`. (@beauby) 352 | - [#1106](https://github.com/rails-api/active_model_serializers/pull/1106) Add Style enforcer (via Rubocop) (@bf4) 353 | - [#1079](https://github.com/rails-api/active_model_serializers/pull/1079) Add ArraySerializer#object like Serializer (@bf4) 354 | - [#1096](https://github.com/rails-api/active_model_serializers/pull/1096) Fix definition of serializer attributes with multiple calls to `attri… (@beauby) 355 | - [#1105](https://github.com/rails-api/active_model_serializers/pull/1105) Add ActiveRecord-backed fixtures. (@beauby) 356 | - [#1108](https://github.com/rails-api/active_model_serializers/pull/1108) Better lint (@bf4) 357 | - [#1102](https://github.com/rails-api/active_model_serializers/pull/1102) Remove remains of `embed` option. (@beauby) 358 | - [#1090](https://github.com/rails-api/active_model_serializers/pull/1090) Clarify AMS dependencies (@bf4) 359 | - [#1081](https://github.com/rails-api/active_model_serializers/pull/1081) Add configuration option to set resource type to singular/plural (@beauby) 360 | - [#1067](https://github.com/rails-api/active_model_serializers/pull/1067) Fix warnings (@bf4) 361 | - [#1066](https://github.com/rails-api/active_model_serializers/pull/1066) Adding appveyor to the project (@joaomdmoura, @Eric-Guo, @bf4) 362 | - [#1071](https://github.com/rails-api/active_model_serializers/pull/1071) Make testing suite running and pass in Windows (@Eric-Guo, @bf4) 363 | - [#1041](https://github.com/rails-api/active_model_serializers/pull/1041) Adding pagination links (@bacarini) 364 | * adds support for `pagination links` at top level of JsonApi adapter 365 | - [#1063](https://github.com/rails-api/active_model_serializers/pull/1063) Lead by example: lint PORO model (@bf4) 366 | - [#1](https://github.com/rails-api/active_model_serializers/pull/1) Test caller line parsing and digesting (@bf4) 367 | - [#1048](https://github.com/rails-api/active_model_serializers/pull/1048) Let FlattenJson adapter decide it doesn't include meta (@bf4) 368 | - [#1060](https://github.com/rails-api/active_model_serializers/pull/1060) Update fragment cache to support namespaced objects (@aaronlerch) 369 | - [#1052](https://github.com/rails-api/active_model_serializers/pull/1052) Use underscored json_root when serializing a collection (@whatthewhat) 370 | - [#1051](https://github.com/rails-api/active_model_serializers/pull/1051) Fix some invalid JSON in docs (@tjschuck) 371 | - [#1049](https://github.com/rails-api/active_model_serializers/pull/1049) Fix incorrect s/options = {}/options ||= {} (@bf4) 372 | - [#1037](https://github.com/rails-api/active_model_serializers/pull/1037) allow for type attribute (@lanej) 373 | - [#1034](https://github.com/rails-api/active_model_serializers/pull/1034) allow id attribute to be overriden (@lanej) 374 | - [#1035](https://github.com/rails-api/active_model_serializers/pull/1035) Fixed Comments highlight (@artLopez) 375 | - [#1031](https://github.com/rails-api/active_model_serializers/pull/1031) Disallow to define multiple associations at once (@bolshakov) 376 | - [#1032](https://github.com/rails-api/active_model_serializers/pull/1032) Wrap railtie requirement with rescue (@elliotlarson) 377 | - [#1026](https://github.com/rails-api/active_model_serializers/pull/1026) Bump Version Number to 0.10.0.rc2 (@jfelchner) 378 | - [#985](https://github.com/rails-api/active_model_serializers/pull/985) Associations implementation refactoring (@bolshakov) 379 | - [#954](https://github.com/rails-api/active_model_serializers/pull/954) Encapsulate serialization in ActiveModel::SerializableResource (@bf4) 380 | - [#972](https://github.com/rails-api/active_model_serializers/pull/972) Capture app warnings on test run (@bf4) 381 | - [#1019](https://github.com/rails-api/active_model_serializers/pull/1019) Improve README.md (@baojjeu) 382 | - [#998](https://github.com/rails-api/active_model_serializers/pull/998) Changing root to model class name (@joaomdmoura) 383 | - [#1006](https://github.com/rails-api/active_model_serializers/pull/1006) Fix adapter inflection bug for api -> API (@bf4) 384 | - [#1016](https://github.com/rails-api/active_model_serializers/pull/1016) require rails/railtie before subclassing Rails::Railtie (@bf4) 385 | - [#1013](https://github.com/rails-api/active_model_serializers/pull/1013) Root option with empty array support (@vyrak, @mareczek) 386 | - [#994](https://github.com/rails-api/active_model_serializers/pull/994) Starting Docs structure (@joaomdmoura) 387 | - [#1007](https://github.com/rails-api/active_model_serializers/pull/1007) Bug fix for ArraySerializer json_key (@jiajiawang) 388 | - [#1003](https://github.com/rails-api/active_model_serializers/pull/1003) Fix transient test failures (@Rodrigora) 389 | - [#996](https://github.com/rails-api/active_model_serializers/pull/996) Add linter for serializable resource (@bf4) 390 | - [#990](https://github.com/rails-api/active_model_serializers/pull/990) Adding json-api meta test (@joaomdmoura) 391 | - [#984](https://github.com/rails-api/active_model_serializers/pull/984) Add option "key" to serializer associations (@Rodrigora) 392 | - [#982](https://github.com/rails-api/active_model_serializers/pull/982) Fix typo (@bf4) 393 | - [#981](https://github.com/rails-api/active_model_serializers/pull/981) Remove unused PORO#to_param (@bf4) 394 | - [#978](https://github.com/rails-api/active_model_serializers/pull/978) fix generators template bug (@regonn) 395 | - [#975](https://github.com/rails-api/active_model_serializers/pull/975) Fixes virtual value not being used (@GriffinHeart) 396 | - [#970](https://github.com/rails-api/active_model_serializers/pull/970) Fix transient tests failures (@Rodrigora) 397 | - [#962](https://github.com/rails-api/active_model_serializers/pull/962) Rendering objects that doesn't have serializers (@bf4, @joaomdmoura, @JustinAiken) 398 | - [#939](https://github.com/rails-api/active_model_serializers/pull/939) Use a more precise generated cache key (@aaronlerch) 399 | - [#971](https://github.com/rails-api/active_model_serializers/pull/971) Restore has_one to generator (@bf4) 400 | - [#965](https://github.com/rails-api/active_model_serializers/pull/965) options fedault valueserializable_hash and as_json (@bf4) 401 | - [#959](https://github.com/rails-api/active_model_serializers/pull/959) TYPO on README.md (@kangkyu) 402 | 403 | ### [v0.10.0.rc2 (2015-06-16)](https://github.com/rails-api/active_model_serializers/compare/v0.10.0.rc1...v0.10.0.rc2) 404 | - [#958](https://github.com/rails-api/active_model_serializers/pull/958) Splitting json adapter into two (@joaomdmoura) 405 | * adds FlattenJSON as default adapter 406 | - [#953](https://github.com/rails-api/active_model_serializers/pull/953) use model name to determine the type (@lsylvester) 407 | * uses model name to determine the type 408 | - [#949](https://github.com/rails-api/active_model_serializers/pull/949) Don't pass serializer option to associated serializers (@bf4, @edwardloveall) 409 | - [#902](https://github.com/rails-api/active_model_serializers/pull/902) Added serializer file digest to the cache_key (@cristianbica) 410 | - [#948](https://github.com/rails-api/active_model_serializers/pull/948) AMS supports JSONAPI 1.0 instead of RC4 (@SeyZ) 411 | - [#936](https://github.com/rails-api/active_model_serializers/pull/936) Include meta when using json adapter with custom root (@chrisbranson) 412 | - [#942](https://github.com/rails-api/active_model_serializers/pull/942) Small code styling issue (@thiagofm) 413 | - [#930](https://github.com/rails-api/active_model_serializers/pull/930) Reverting PR #909 (@joaomdmoura) 414 | - [#924](https://github.com/rails-api/active_model_serializers/pull/924) Avoid unnecessary calls to attribute methods when fragment caching (@navinpeiris) 415 | - [#925](https://github.com/rails-api/active_model_serializers/pull/925) Updates JSON API Adapter to generate RC4 schema (@benedikt) 416 | * adds JSON API support 1.0 417 | - [#918](https://github.com/rails-api/active_model_serializers/pull/918) Adding rescue_with_handler to clear state (@ryansch) 418 | - [#909](https://github.com/rails-api/active_model_serializers/pull/909) Defining Json-API Adapter as Default (@joaomdmoura) 419 | * remove root key option and split JSON adapter 420 | - [#914](https://github.com/rails-api/active_model_serializers/pull/914) Prevent possible duplicated attributes in serializer (@groyoh) 421 | - [#880](https://github.com/rails-api/active_model_serializers/pull/880) Inabling subclasses serializers to inherit attributes (@groyoh) 422 | - [#913](https://github.com/rails-api/active_model_serializers/pull/913) Avoiding the serializer option when instantiating a new one for ArraySerializer Fixed #911 (@groyoh) 423 | - [#897](https://github.com/rails-api/active_model_serializers/pull/897) Allow to define custom serializer for given class (@imanel) 424 | - [#892](https://github.com/rails-api/active_model_serializers/pull/892) Fixed a bug that appeared when json adapter serialize a nil association (@groyoh) 425 | - [#895](https://github.com/rails-api/active_model_serializers/pull/895) Adding a test to cover 'meta' and 'meta_key' attr_readers (@adomokos) 426 | - [#894](https://github.com/rails-api/active_model_serializers/pull/894) Fixing typos in README.md (@adomokos) 427 | - [#888](https://github.com/rails-api/active_model_serializers/pull/888) Changed duplicated test name in action controller test (@groyoh) 428 | - [#890](https://github.com/rails-api/active_model_serializers/pull/890) Remove unused method `def_serializer` (@JustinAiken) 429 | - [#887](https://github.com/rails-api/active_model_serializers/pull/887) Fixing tests on JRuby (@joaomdmoura) 430 | - [#885](https://github.com/rails-api/active_model_serializers/pull/885) Updates rails versions for test and dev (@tonyta) 431 | 432 | ### [v0.10.0.rc1 (2015-04-22)](https://github.com/rails-api/active_model_serializers/compare/86fc7d7227f3ce538fcb28c1e8c7069ce311f0e1...v0.10.0.rc1) 433 | - [#810](https://github.com/rails-api/active_model_serializers/pull/810) Adding Fragment Cache to AMS (@joaomdmoura) 434 | * adds fragment cache support 435 | - [#868](https://github.com/rails-api/active_model_serializers/pull/868) Fixed a bug that appears when a nil association is included (@groyoh) 436 | - [#861](https://github.com/rails-api/active_model_serializers/pull/861) README: Add emphasis to single-word difference (@machty) 437 | - [#858](https://github.com/rails-api/active_model_serializers/pull/858) Included resource fixes (@mateomurphy) 438 | - [#853](https://github.com/rails-api/active_model_serializers/pull/853) RC3 Updates for JSON API (@mateomurphy) 439 | - [#852](https://github.com/rails-api/active_model_serializers/pull/852) Fix options merge order in `each_association` (@mateomurphy) 440 | - [#850](https://github.com/rails-api/active_model_serializers/pull/850) Use association value for determining serializer used (@mateomurphy) 441 | - [#843](https://github.com/rails-api/active_model_serializers/pull/843) Remove the mailing list from the README (@JoshSmith) 442 | - [#842](https://github.com/rails-api/active_model_serializers/pull/842) Add notes on how you can help to contributing documentation (@JoshSmith) 443 | - [#833](https://github.com/rails-api/active_model_serializers/pull/833) Cache serializers for class (@lsylvester) 444 | - [#837](https://github.com/rails-api/active_model_serializers/pull/837) Store options in array serializers (@kurko) 445 | - [#836](https://github.com/rails-api/active_model_serializers/pull/836) Makes passed in options accessible inside serializers (@kurko) 446 | - [#773](https://github.com/rails-api/active_model_serializers/pull/773) Make json api adapter 'include' option accept an array (@sweatypitts) 447 | - [#830](https://github.com/rails-api/active_model_serializers/pull/830) Add contributing readme (@JoshSmith) 448 | - [#811](https://github.com/rails-api/active_model_serializers/pull/811) Reimplement serialization scope and scope_name (@mateomurphy) 449 | - [#725](https://github.com/rails-api/active_model_serializers/pull/725) Support has_one to be compatible with 0.8.x (@ggordon) 450 | * adds `has_one` attribute for backwards compatibility 451 | - [#822](https://github.com/rails-api/active_model_serializers/pull/822) Replace has_one with attribute in template (@bf4) 452 | - [#821](https://github.com/rails-api/active_model_serializers/pull/821) Fix explicit serializer for associations (@wjordan) 453 | - [#798](https://github.com/rails-api/active_model_serializers/pull/798) Fix lost test `test_include_multiple_posts_and_linked` (@donbobka) 454 | - [#807](https://github.com/rails-api/active_model_serializers/pull/807) Add Overriding attribute methods section to README. (@alexstophel) 455 | - [#693](https://github.com/rails-api/active_model_serializers/pull/693) Cache Support at AMS 0.10.0 (@joaomdmoura) 456 | * adds cache support to attributes and associations. 457 | - [#792](https://github.com/rails-api/active_model_serializers/pull/792) Association overrides (@kurko) 458 | * adds method to override association 459 | - [#794](https://github.com/rails-api/active_model_serializers/pull/794) add to_param for correct URL generation (@carlesjove) 460 | 461 | ### v0.10.0-pre 462 | 463 | - [Introduce Adapter](https://github.com/rails-api/active_model_serializers/commit/f00fe5595ddf741dc26127ed8fe81adad833ead5) 464 | - Prefer `ActiveModel::Serializer` to `ActiveModelSerializers`: 465 | - [Namespace](https://github.com/rails-api/active_model_serializers/commit/729a823868e8c7ac86c653fcc7100ee511e08cb6#diff-fe7aa2941c19a41ccea6e52940d84016). 466 | - [README](https://github.com/rails-api/active_model_serializers/commit/4a2d9853ba7486acc1747752982aa5650e7fd6e9). 467 | -------------------------------------------------------------------------------- /CHANGELOG-prehistory.md: -------------------------------------------------------------------------------- 1 | ## Prehistory 2 | 3 | - [Changing Serialization/Serializers namespace to `Serializable` (November 30, 2011)](https://github.com/rails/rails/commit/8896b4fdc8a543157cdf4dfc378607ebf6c10ab0) 4 | - [Merge branch 'serializers'. This implements the ActiveModel::Serializer object. Includes code, tests, generators and guides. From José and Yehuda with love.](https://github.com/rails/rails/commit/fcacc6986ab60f1fb2e423a73bf47c7abd7b191d) 5 | - But [was reverted](https://github.com/rails/rails/commit/5b2eb64ceb08cd005dc06b721935de5853971473). 6 | '[Revert the serializers API as other alternatives are now also under discussion](https://github.com/rails/rails/commit/0a4035b12a6c59253cb60f9e3456513c6a6a9d33)'. 7 | - [Proposed Implementation to Rails 3.2 by @wycats and @josevalim (November 25, 2011)](https://github.com/rails/rails/pull/3753) 8 | - [Creation of `ActionController::Serialization`, initial serializer 9 | support (September, 26 2011)](https://github.com/rails/rails/commit/8ff7693a8dc61f43fc4eaf72ed24d3b8699191fe). 10 | - [Docs and CHANGELOG](https://github.com/rails/rails/commit/696d01f7f4a8ed787924a41cce6df836cd73c46f) 11 | - [Deprecation of ActiveModel::Serialization to ActiveModel::Serializable](https://github.com/rails/rails/blob/696d01f7f4a8ed787924a41cce6df836cd73c46f/activemodel/lib/active_model/serialization.rb) 12 | - [Creation of `ActiveModel::Serialization` from `ActiveModel::Serializer` in Rails (2009)](https://github.com/rails/rails/commit/c6bc8e662614be711f45a8d4b231d5f993b024a7#diff-d029b9768d8df0407a35804a468e3ae5) 13 | - [Integration of `ActiveModel::Serializer` into `ActiveRecord::Serialization`](https://github.com/rails/rails/commit/783db25e0c640c1588732967a87d65c10fddc08e) 14 | - [Creation of `ActiveModel::Serializer` in Rails (2009)](https://github.com/rails/rails/commit/d2b78b3594b9cc9870e6a6ebfeb2e56d00e6ddb8#diff-80d5beeced9bdc24ca2b04a201543bdd) 15 | - [Creation of `ActiveModel::Serializers::JSON` in Rails (2009)](https://github.com/rails/rails/commit/fbdf706fffbfb17731a1f459203d242414ef5086) 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Dev 2 | 3 | ### [master (unreleased)](https://github.com/rails-api/active_model_serializers/compare/master..dev) 4 | 5 | Breaking changes: 6 | 7 | Features: 8 | 9 | Fixes: 10 | 11 | Misc: 12 | 13 | ## [0.10.x](CHANGELOG-0-10.md) 14 | 15 | ## [0.09.x](CHANGELOG-0-09.md) 16 | 17 | ## [0.08.x](CHANGELOG-0-08.md) 18 | 19 | ## [Prehistory](CHANGELOG-prehistory.md) 20 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting one of the owners listed at https://rubygems.org/gems/active_model_serializers. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Have an issue? 2 | 3 | Before opening an issue, try the following: 4 | 5 | ##### Consult the documentation 6 | 7 | See if your issue can be resolved by information in the [documentation](README.md). 8 | 9 | ##### Check for an existing issue 10 | 11 | Take a look at the issues to see if a similar one has already been created. If 12 | one exists, please add any additional information that might expedite 13 | resolution. 14 | 15 | #### Open an issue 16 | 17 | If the documentation wasn't able to help resolve the issue and no issue already 18 | exists, please open a new issue with the following in mind: 19 | 20 | - Please make sure only to include one issue per report. If you encounter 21 | multiple, unrelated issues, please report them as such. 22 | - Be detailed. Provide backtraces and example code when possible. Provide 23 | information about your environment. e.g., Ruby version, rails version, etc. 24 | - Own your issue. Actively participate in the discussion and help drive the 25 | issue to closure. 26 | - If you resolve your own issue, please share the details on the issue and close 27 | it out. Others might have the same issue and sharing solutions is helpful. 28 | 29 | ## Contributing 30 | 31 | Contributing can be done in many ways and is not exclusive to code. If you have 32 | thoughts on a particular issue or feature, we encourage you to open new issues 33 | for discussion or add your comments to existing ones. 34 | 35 | #### Pull requests 36 | 37 | We also gladly welcome pull requests. When preparing to work on pull request, 38 | please adhere to these standards: 39 | 40 | - Base work on the relevant branch: 41 | [0.10-stable](https://github.com/rails-api/active_model_serializers/tree/0-10-stable) 42 | or 43 | [0.9-stable](https://github.com/rails-api/active_model_serializers/tree/0-9-stable) 44 | or 45 | [0.8-stable](https://github.com/rails-api/active_model_serializers/tree/0-8-stable) 46 | - Squash your commits and regularly rebase off master. 47 | - Provide a description of the changes contained in the pull request. 48 | - Note any specific areas that should be reviewed. 49 | - Include tests. 50 | - The test suite must pass on [supported Ruby versions](.travis.yml) 51 | - Include updates to the [documentation](docs) 52 | where applicable. 53 | - Update the 54 | [CHANGELOG](CHANGELOG.md) 55 | to the appropriate sections with a brief description of the changes. 56 | - Do not change the VERSION file. 57 | 58 | #### Running tests 59 | 60 | Run all tests 61 | 62 | `$ rake test` 63 | 64 | Run a single test suite 65 | 66 | `$ rake test TEST=path/to/test.rb` 67 | 68 | Run a single test 69 | 70 | `$ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"` 71 | 72 | Run tests against different Rails versions by setting the RAILS_VERSION variable 73 | and bundling gems. (save this script somewhere executable and run from top of AMS repository) 74 | 75 | ```bash 76 | #!/usr/bin/env bash 77 | 78 | rcommand='puts YAML.load_file("./.travis.yml")["env"]["matrix"].join(" ").gsub("RAILS_VERSION=", "")' 79 | versions=$(ruby -ryaml -e "$rcommand") 80 | 81 | for version in ${versions[@]}; do 82 | export RAILS_VERSION="$version" 83 | rm -f Gemfile.lock 84 | bundle check || bundle --local || bundle 85 | bundle exec rake test 86 | if [ "$?" -eq 0 ]; then 87 | # green in ANSI 88 | echo -e "\033[32m **** Tests passed against Rails ${RAILS_VERSION} **** \033[0m" 89 | else 90 | # red in ANSI 91 | echo -e "\033[31m **** Tests failed against Rails ${RAILS_VERSION} **** \033[0m" 92 | read -p '[Enter] any key to continue, [q] to quit...' prompt 93 | if [ "$prompt" = 'q' ]; then 94 | unset RAILS_VERSION 95 | exit 1 96 | fi 97 | fi 98 | unset RAILS_VERSION 99 | done 100 | ``` 101 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Steve Klabnik 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ActiveModelSerializers 2 | 3 | ## About 4 | 5 | ActiveModelSerializers is undergoing some renovations. See [Development Status](#status-of-ams). 6 | 7 | ## Getting Help 8 | 9 | If you find a bug, please report an [Issue](https://github.com/rails-api/active_model_serializers/issues/new) 10 | and see our [contributing guide](CONTRIBUTING.md). 11 | 12 | If you have a question, please [post to Stack Overflow](http://stackoverflow.com/questions/tagged/active-model-serializers). 13 | 14 | If you'd like to chat, we have a [community slack](http://amserializers.herokuapp.com). 15 | 16 | Thanks! 17 | 18 | ## Documentation 19 | 20 | If you're reading this at https://github.com/rails-api/active_model_serializers you are 21 | reading documentation for our `master`, which is not yet released. 22 | 23 | 24 | 25 | 29 | 34 | 39 | 40 | 41 | 45 | 50 | 51 | 52 | 53 | 57 | 62 | 63 | 64 |
26 | 0.10 (0-10-stable) Documentation 27 | 28 | 30 | 31 | 32 | 33 | 35 | 36 | Guides 37 | 38 |
42 | 0.9 (0-9-stable) Documentation 43 | 44 | 46 | 47 | 48 | 49 |
54 | 0.8 (0-8-stable) Documentation 55 | 56 | 58 | 59 | 60 | 61 |
65 | 66 | 67 | ## Status of AMS 68 | 69 | ### *Status*: 70 | 71 | - ❗️ All existing PRs against master will need to be closed and re-opened against 0-10-stable, if so desired 72 | - ❗️ Master, for the moment, won't have any released version of AMS on it. 73 | - :eyes: See below for [alternatives](#alternatives) 74 | 75 | 76 | ### *Changes to 0.10.x maintenance*: 77 | 78 | - The 0.10.x version has become a huge maintenance version. We had hoped to get it in shape for a 1.0 release, but it is clear that isn't going to happen. Almost none of the maintainers from 0.8, 0.9, or earlier 0.10 are still working on AMS. We'll continue to maintain 0.10.x on the 0-10-stable branch, but maintainers won't otherwise be actively developing on it. 79 | - We may choose to make a 0.11.x ( 0-11-stable) release based on 0-10-stable that just removes the deprecations. 80 | 81 | ### *What's happening to AMS*: 82 | 83 | - There's been a lot of churn around AMS since it began back in [Rails 3.2](CHANGELOG-prehistory.md) and a lot of new libraries are around and the JSON:API spec has reached 1.0. 84 | - If there is to be a 1.0 release of AMS, it will need to address the general needs of serialization in much the way ActiveJob can be used with different workers. 85 | - The next major release *is* in development. We're starting simple and avoiding, at least at the outset, all the complications in AMS version, especially all the implicit behavior from guessing the serializer, to the association's serializer, to the serialization type, etc. 86 | - The basic idea is that models to serializers are a one to many relationship. Everything will need to be explicit. If you want to serialize a User with a UserSerializer, you'll need to call it directly. The serializer will essentially be for defining a basic JSON:API resource object: id, type, attributes, and relationships. The serializer will have an as_json method and can be told which fields (attributes/relationships) to serialize to JSON and will likely *not* know serialize any more than the relations id and type. Serializing anything more about the relations would require code that called a serializer. (This is still somewhat in discussion). 87 | - If this works out, the idea is to get something into Rails that existing libraries can use. 88 | 89 | See [PR 2121](https://github.com/rails-api/active_model_serializers/pull/2121) where these changes were introduced for more information and any discussion. 90 | 91 | 92 | 93 | ## Alternatives 94 | 95 | - [jsonapi-rb](http://jsonapi-rb.org/) is a [highly performant](https://gist.github.com/NullVoxPopuli/748e89ddc1732b42fdf42435d773734a) and modular JSON:API-only implementation. There's a vibrant community around it that has produced projects such as [JSON:API Suite](https://jsonapi-suite.github.io/jsonapi_suite_deprecated/). 96 | - [fast_jsonapi](https://github.com/fast-jsonapi/fast_jsonapi) is a lightning fast JSON:API serializer for Ruby Objects. 97 | - [jsonapi-resources](https://github.com/cerebris/jsonapi-resources) is a popular resource-focused framework for implementing JSON:API servers. 98 | - [blueprinter](https://github.com/procore/blueprinter) is a fast, declarative, and API spec agnostic serializer that uses composable views to reduce duplication. From your friends at Procore. 99 | - [Alba](https://github.com/okuramasafumi/alba) is fast and spec agnostic serialization solution. It has some unique features such as global or per-resource error handling. 100 | - [Transmutation](https://github.com/spellbook-technology/transmutation) is fast and lightweight JSON attribute serialization solution. It provides an intuitive serializer lookup, inspired from AMS. 101 | 102 | 103 | For benchmarks against alternatives, see https://github.com/rails-api/active_model_serializers/tree/benchmarks 104 | 105 | 106 | 107 | ## Semantic Versioning 108 | 109 | This project adheres to [semver](http://semver.org/) 110 | 111 | ## Contributing 112 | 113 | See [CONTRIBUTING.md](CONTRIBUTING.md) 114 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | begin 2 | require 'bundler/setup' 3 | rescue LoadError 4 | puts 'You must `gem install bundler` and `bundle install` to run rake tasks' 5 | end 6 | -------------------------------------------------------------------------------- /active_model_serializers.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = 'active_model_serializers' 5 | spec.version = "1.0.0-dev" 6 | spec.platform = Gem::Platform::RUBY 7 | spec.authors = ['Steve Klabnik'] 8 | spec.email = ['steve@steveklabnik.com'] 9 | spec.summary = 'Conventions-based JSON generation for Rails.' 10 | spec.description = 'ActiveModel::Serializers allows you to generate your JSON in an object-oriented and convention-driven manner.' 11 | spec.homepage = 'https://github.com/rails-api/active_model_serializers' 12 | spec.license = 'MIT' 13 | 14 | spec.files = `git ls-files -z`.split("\x0") 15 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 16 | spec.require_paths = ['lib'] 17 | spec.executables = [] 18 | 19 | spec.required_ruby_version = '>= 2.1' 20 | end 21 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build}-{branch} 2 | 3 | skip_tags: true 4 | 5 | cache: 6 | - vendor/bundle 7 | 8 | test_script: 9 | - true 10 | 11 | build: off 12 | -------------------------------------------------------------------------------- /docs/rfcs/template.md: -------------------------------------------------------------------------------- 1 | - Start Date: (YYYY-MM-DD) 2 | - RFC PR: https://github.com/rails-api/active_model_serializers/pull/dddd 3 | - ActiveModelSerializers Issue: https://github.com/rails-api/active_model_serializers/issues/dddd 4 | 5 | # Summary 6 | 7 | # Motivation 8 | 9 | # Detailed design 10 | 11 | # Drawbacks 12 | 13 | # Alternatives 14 | 15 | # Unresolved questions 16 | --------------------------------------------------------------------------------