Commit Graph

146 Commits

Author SHA1 Message Date
Taylor Jones
da55cd181c addressing comments / concerns 2016-03-01 08:40:45 -05:00
Taylor Jones
e9f259697a addressing pull request comments 2016-02-29 10:56:14 -05:00
CodedBeardedSignedTaylor
6a8da1f664 adding ruby tag to code blocks 2016-02-28 22:45:45 -05:00
bobba surendranath chowdary
8b5da690fe Removes DESIGN.textile doc and update ARCHITECTURE.md
The old DESIGN.textile was removed and replace by reference to 0.8 and
0.9 READMEs within the ARCHITECTURE.md docs.
2016-02-29 04:41:47 +01:00
CodedBeardedSignedTaylor
558769981e rough draft 2016-02-28 22:41:26 -05:00
Yohan Robert
8a040052af Merge pull request #1535 from bf4/domitian-move-namespace-of-adapter-to-active-model-serializers
Moved the adapter and adapter folder to active_model_serializers folder and changed the module namespace
2016-02-28 12:58:36 +01:00
Ben Mills
5d9039e172 Adjust GitHub templates 2016-02-26 10:43:52 -07:00
Benjamin Fleischer
e35390623d Improve adapter test coverage per groyoh 2016-02-25 23:08:20 -06:00
Benjamin Fleischer
25c9df0b97 Merge branch 'master' into domitian-move-namespace-of-adapter-to-active-model-serializers
Conflicts:
	CHANGELOG.md
	lib/active_model/serializer/adapter/attributes.rb
	lib/active_model/serializer/adapter/cached_serializer.rb
	lib/active_model/serializer/adapter/fragment_cache.rb
	lib/active_model/serializer/adapter/json_api.rb
	lib/active_model/serializer/adapter/json_api/link.rb
	test/adapter/fragment_cache_test.rb
	test/adapter/json_api/links_test.rb
	test/adapter/json_api/resource_type_config_test.rb
2016-02-23 23:21:49 -06:00
bobba surendranath chowdary
252f9c4ae9 Moved the adapter and adapter folder to active_model_serializers folder and changed the module namespace
Changed the namespace in adapters and folder to active_model_serializers from active_model::serializer

Changed namespace of adapters in serializers and other folders

Moved adapter_for_test file to active_model_serializers folder and changed namespace of adapter inside the test file

Require ActiveSupport's string/inflections

We depend on string/inflections to define String#underscore.

Refactor JsonApi adapter to avoid redundant computations.

Update readme.md to link to v0.10.0.rc4

changed namespace of adapter folder testcases

Changed all namespaces of adapter under active_moder_serializers

Namespaced IncludeTree which is from serializer module, so needed to namespace it properly

Fixed wrong namsepacing of fieldset

namespace change in deserializer json_api

Fixed the namespace for collection serializer when used inside adapter, changed namespace for adapter to new namespace which I had forgotten previously

Modified logging test and adapter test cases to make the testcases pass

Changed the yardoc links,as old links are not taking to documentation pages,proper links for 0.10,0.9 and 0.8 in rubydoc

Rubocop errors are fixed by underscore naming unused variables

Moved the require of adapter to serializable resource

Remoeved adapter dependency inside serializer and added warning to Serializer::adapter method

Fixed frament cache test which is calling Serializer.adapter

Changed the name of lookup_adapter_from_config to configured_adapter

Changed the docs which will show the new namespace of adapters

Rubocop fix
2016-02-23 21:49:58 -06:00
Yohan Robert
727d7631ae Add symbol support for ActiveModel::Serializer.type method
The ActiveModel::Serializer.type method now accepts symbol as paremeter:
class AuthorSerializer < ActiveModel::Serializer
  type :profile
end
The test file for the type was also refactored.
2016-02-19 17:05:13 +01:00
Benjamin Fleischer
344d09d36e Merge pull request #1472 from edwinlunando/master
[DOC] update JSON adapter pagination links how to guide
2016-02-12 14:13:40 -06:00
Benjamin Fleischer
5b953ff40f Address concerns from #1018 commit c59668e 2016-02-08 17:55:15 -06:00
Benjamin Fleischer
c59668e7a8 Merge branch 'leandrocp-add-top-level-links'
Needs followup
- https://github.com/rails-api/active_model_serializers/pull/1018#discussion_r51733900
- https://github.com/rails-api/active_model_serializers/pull/1018#discussion_r51734779
- https://github.com/rails-api/active_model_serializers/pull/1018#discussion_r51735145
- https://github.com/rails-api/active_model_serializers/pull/1018#discussion_r51735218
2016-02-08 17:44:05 -06:00
bobba surendranath chowdary
68f09e59c4 Fixed a documentation error regarding adapter key constant, added tests
for SerializableResource::use_adapter?
2016-02-08 15:27:56 +05:30
Leandro Cesquini Pereira
b55fc32ba2 improve doc as suggested by @bf4 2016-02-03 10:22:17 -02:00
Leandro Cesquini Pereira
1844c162f1 Adds support for top-level links to JsonApi adapter
http://jsonapi.org/format/#document-top-level

fix failing tests

support for top-level links limited to jsonapi adapter

Move docs from README to docs/ dir

move links to json-api adapter & create Links class to hold links data
2016-02-03 10:16:22 -02:00
Peter Wagenet
efdd466147 Namespace is included in auto-registered adapters [ci skip] 2016-01-28 15:48:18 -08:00
Peter Wagenet
75fdbfa992 Adapters inherit from Adapter::Base 2016-01-28 14:27:53 -08:00
Benjamin Fleischer
7d4f47d4a2 Add an RFC template 2016-01-28 12:59:57 -06:00
Benjamin Fleischer
65093055d6 Merge pull request #1310 from maurogeorge/patch-12
RFC: Primary namespace: ActiveModel::Serializer, ActiveModel::Serializers, vs. ActiveModelSerializers
2016-01-28 12:54:52 -06:00
Edwin Lunando
2678896a9c update JSON adapter pagination links 2016-01-28 13:51:19 +07:00
Nate Sullivan
0a937a0fba Use new block-based attribute override in docs 2016-01-23 18:59:18 -08:00
Nate Sullivan
da85d944d4 Remove unrelated code from attribute override examples 2016-01-23 18:50:18 -08:00
Benjamin Fleischer
8981683b9f Merge pull request #1352 from bf4/railties
Fix generators (@dgynn); load Railtie only with Rails, ensures caching configured
2016-01-18 23:24:40 -05:00
Lucas Hosseini
f2d59b20ca Update rendering.md 2016-01-17 16:58:35 +01:00
Benjamin Fleischer
d3bdc9be57 Replace load hook :active_model_serializers with :action_controller 2016-01-15 01:58:14 -06:00
Benjamin Fleischer
92e8a0a246 Merge pull request #1417 from koryteg/custom_root_docs
[DOCS] added documentation for adding custom root
2016-01-15 00:52:56 -06:00
Mauro George
5058694f4a Create assert_response_schema test helper
It is a common pattern to use JSON Schema to validate a API response[1], [2]
and [3].

This patch creates the `assert_response_schema` test helper that helps people do
this kind of validation easily on the controller tests.

[1]: https://robots.thoughtbot.com/validating-json-schemas-with-an-rspec-matcher
[2]: https://github.com/sharethrough/json-schema-rspec
[3]: https://github.com/rails-api/active_model_serializers/issues/1011#issuecomment-127608121
2016-01-15 00:45:56 -06:00
Mauro George
2f8c430a09 Update the RFC to use ActiveModelSerializers
After some internal discussion was decided to use the ActiveModelSerializers
namespace.

This patch update the content following this idea.

Ref:
https://github.com/rails-api/active_model_serializers/pull/1310/files#r45947587
https://github.com/rails-api/active_model_serializers/pull/1310/files#r47144210
2016-01-14 19:21:33 -02:00
Benjamin Fleischer
e60937bc2f Remove duplicate documentation 2016-01-13 21:47:08 -06:00
Mauro George
c0b99c980c Bring back assert_serializer for controller testing
The `assert_serializer` test helper was added in 0.9.0.apha1[1],
and was not included in 0.10.

This patch brings back the `assert_serializer` test helper. This is the last
revision[2] that has the helper. The original helper was used as base.

[1]: https://github.com/rails-api/active_model_serializers/pull/596
[2]: 610aeb2e92

- Create the AssertSerializer

- Use the Test namespace

- Make the tests pass on the Rails master
  - Rails 5 does not include `assert_template` but we need this on the tests of
the helper.
  - This add the `rails-controller-testing` to keep support on `assert_template`.

- Only load test helpers in the test environment
2016-01-13 20:54:22 -06:00
Benjamin Fleischer
dde843d162 Add serialization docs PR request note for conditional attributes 2016-01-13 10:19:07 -06:00
Igor Zubkov
aa8e306782 Fix ARCHITECTURE.md 2016-01-13 17:45:18 +02:00
Lucas Hosseini
3aeb34b0b8 Add docs for deserialization. 2016-01-13 08:40:38 +01:00
Kory Tegman
aeefb6a080 revised docs to reflect the feedback 2016-01-06 22:21:19 -08:00
Kory Tegman
d153dfe2cd added documentation for adding custom root 2016-01-06 15:57:49 -08:00
Mauro George
a183645ed4 Create the Namespace RFC
[ci skip]

Update the RFC adding info from discussion

[ci skip]
2016-01-06 19:13:31 -02:00
Benjamin Fleischer
81b1654c4e Merge pull request #1388 from bf4/restore_docs_from_older_releases
Restore docs from older releases
2016-01-03 23:10:41 -06:00
George Millo
fdbc13c2de fix broken link 2015-12-31 16:44:54 +01:00
CorainChicago
66b068c542 fix link on Getting Started
update link on Getting Started to use the relative path
2015-12-29 22:52:22 -06:00
Benjamin Fleischer
7d678844ae Add original design doc from 0.8
https://github.com/rails-api/active_model_serializers/blob/0-8-stable/DESIGN.textile
2015-12-23 09:45:45 -06:00
Benjamin Fleischer
fce856fc83 Merge pull request #1371 from bf4/documentation_updates
[DOCS] Refactor, update, create documentation
2015-12-20 22:30:44 -06:00
Benjamin Fleischer
30fd9d9eb7 Merge pull request #1353 from bf4/disable_serializer_lookup
Allow users to globally opt out of automatic serializer lookup
2015-12-20 20:04:16 -06:00
Benjamin Fleischer
13c9a90fa5 Fix grammar per nullvoxpopli [ci skip] 2015-12-16 12:56:55 -06:00
Benjamin Fleischer
9c3431db9e Fix grammar per duduribeiro [ci skip] 2015-12-15 21:34:25 -06:00
Benjamin Fleischer
51af5a4b76 fix typo caught by duduribeiro 2015-12-15 21:29:39 -06:00
Benjamin Fleischer
ce17a1b305 [DOCS] Refactor, update, create documentation [ci skip] 2015-12-14 14:38:29 -06:00
Julian Paas
d85a17bb33 Grape formatter feature requested in #1258
- adds handling for when the returned resource is not serializable via ams
 - fix for when resource is an Array
 - Moves grape include to grape namespace. Changes Enumerable to Array because a plain hash is enumerable.
 - Add integration test
 - Refine scope of Grape version dependency
 - Assert that the response is equal to a manually defined JSON string
 - Add single module to include in Grape projects
 - Create a Serializable Resource to test rails-api from Grape
 - Update docs
 - Fix discrepency between ActiveRecord 4.0 - 4.1 and 4.2
 - Updated Changelog
 - Remove parens from `render`, use `serializable` in all tests.
2015-12-10 10:06:40 +00:00
Benjamin Fleischer
614e349502 Merge pull request #1301 from rails-api/jsonapi_schema
Mapping JSON API spec / schema to AMS [ci skip]
2015-12-09 17:08:57 -06:00
Benjamin Fleischer
5301112c27 Merge pull request #1312 from NullVoxPopuli/integration-docs
[DOCS] begin integration docs
2015-12-03 11:26:06 -06:00
L. Preston Sego III
2dc78c5916 add information about server side changes 2015-12-01 14:49:57 -05:00
Benjamin Fleischer
28394340d8 Add config.serializer_lookup_enabled that defaults true 2015-11-30 00:20:58 -06:00
Trek Glowacki
170db3ba88 Allow users to globally opt out of automatic lookup 2015-11-30 00:15:02 -06:00
L. Preston Sego III
21fe3abdfc make issue number a link 2015-11-27 08:43:15 -05:00
L. Preston Sego III
21873130bb update docs with integration table, and remove the grape placeholder for now 2015-11-27 08:41:29 -05:00
Benjamin Fleischer
d1c44c719d Update for review per maurogeorge feedback 2015-11-19 12:41:51 -06:00
Benjamin Fleischer
21bb306d38 Keep Logging in the ActiveModelSerializers namespace 2015-11-10 03:09:24 -06:00
Mauro George
51424963da ActiveSupport::Notifications render.active_model_serializers
Squashed commits:

Add Logging

Generates logging when renders a serializer.

Tunning performance on notify_active_support

- Use yield over block.call
- Freeze the event name string

Organize the logger architeture

* Keep only the `ActiveModel::Serializer.logger` to follow the same public API we
  have for example to config, like `ActiveModel::Serializer.config.adapter` and
  remove the `ActiveModelSerializers.logger` API.
* Define the logger on the load of the AMS, following the Rails convention on
  Railties [1], [2] and [3].

This way on non Rails apps we have a default logger and on Rails apps we will
use the `Rails.logger` the same way that Active Job do [4].

[1]: 2ad9afe4ff/activejob/lib/active_job/railtie.rb (L9-L11)
[2]: 2ad9afe4ff/activerecord/lib/active_record/railtie.rb (L75-L77)
[3]: 2ad9afe4ff/actionview/lib/action_view/railtie.rb (L19-L21)
[4]: 2ad9afe4ff/activejob/lib/active_job/logging.rb (L10-L11)

Performance tunning on LogSubscriber#render

Move the definition of locals to inside the `info` block this way the code is
executed only when the logger is called.

Remove not needed check on SerializableResource

Use SerializableResource on ActionController integration

On the ActionController was using a adapter, and since the instrumentation is
made on the SerializableResource we need to use the SerializableResource over
the adapter directly. Otherwise the logger is not called on a Rails app.

Use SerializableResource on the ActionController, since this is the main
interface to create and call a serializer.

Using always the SerializableResource we can keep the adapter code more easy to
mantain since no Adapter will need to call the instrumentation, only the
SerializableResource care about this.

Add docs about logging

Add a CHANGELOG entry

Keep the ActiveModelSerializers.logger

Better wording on Logging docs

[ci skip]

Add doc about instrumentation

[ci skip]

Use ActiveModel::Callbacks on the SerializableResource
2015-11-10 03:09:24 -06:00
Lucas Hosseini
831921ff07 Update adapters.md
Fix typos.
2015-10-31 18:51:10 +01:00
L. Preston Sego III
4cb5ad08e7 update ember docs with ember-data issue tracking urlForFindRecord / the inability to use query params on a single resource find 2015-10-30 14:10:17 -04:00
L. Preston Sego III
168ec0ec2a begin integration docs 2015-10-30 13:58:42 -04:00
L. Preston Sego III
11d8fee4d0 added docs for setting up ember for nested resources with the json api adapter
fix typo

fix intra-document links

fix spelling error in nested resources toc link

add example for post collection

Update ember-and-json-api.md

fix typo
2015-10-30 13:25:08 -04:00
Lucas Hosseini
68a751744e Update schema.md 2015-10-26 09:07:37 +01:00
Benjamin Fleischer
14e84640c1 Try to improve readability on github [ci skip] 2015-10-26 01:27:04 -05:00
Benjamin Fleischer
15c296d643 Table formatting? [ci skip] 2015-10-26 01:27:00 -05:00
Benjamin Fleischer
cf34a66527 Mapping JSON API spec / schema to AMS [ci skip] 2015-10-26 01:18:34 -05:00
Benjamin Fleischer
9b0c86546b Merge pull request #1253 from rails-api/architecture
Describe AMS architecture in the big picture
2015-10-22 10:37:46 -05:00
Benjamin Fleischer
8e1245a5b2 Merge pull request #1251 from bf4/collection_serializer
Rename ArraySerializer to CollectionSerializer for clarity
2015-10-22 10:29:02 -05:00
Lucas Hosseini
d3a8006562 Wording and typos. 2015-10-22 04:02:51 +02:00
Benjamin Fleischer
2c8b9b796d Rename ArraySerializer to CollectionSerializer for clarity 2015-10-21 16:53:26 -05:00
Benjamin Fleischer
a5defcb0aa Describe AMS architecture in the big picture [ci skip] 2015-10-21 16:19:00 -05:00
Filippos Vasilakis
91d6215ac4 Update add_pagination_links.md 2015-10-20 14:26:03 +02:00
Benjamin Fleischer
200625fd02 Add image from commit strip [ci skip]
http://www.commitstrip.com/en/2014/05/07/the-truth-behind-open-source-apps/
2015-10-14 17:41:15 -05:00
Lucas Hosseini
9147469842 Extend serializer lookup to the parent serializer. 2015-10-08 18:23:54 +02:00
Benjamin Fleischer
9d7da8afc4 Add support for top level jsonapi member. 2015-10-01 21:22:49 -05:00
Benjamin Fleischer
c6f8d0f5f2 Rename FlattenJson to Attributes (allow plural adapter names) 2015-09-18 10:17:02 -05:00
Benjamin Fleischer
0091be89f8 Consistently refer to the 'JSON API' and the 'JsonApi' adapter 2015-09-17 15:22:28 -05:00
Terminator3
173f21d942 outside controller use tutorial 2015-09-15 15:55:35 -05:00
Bruno Bacarini
9aa237adc2 Fix Markdown to adapters documentation 2015-09-13 21:16:50 -03:00
Lucas Hosseini
ce7a839f3d Extended format for JSONAPI include option. 2015-09-13 22:45:47 +02:00
Benjamin Fleischer
363345b8dd Rename Adapter.get to Adapter.lookup
Per https://github.com/rails-api/active_model_serializers/pull/1017#discussion_r39003855
comment by sandstrom in discussion of the inherited hook

> I'm thinking that it would be better to register adapters manually, without using the hook, i.e.
> have people call ActiveModel::Serializer::Adapter.register directly (perhaps in an initializer).

> Possibly, some inspiration can be taken from how ActiveJob adapters are wired[1].

> [1] a11571cec3/activejob/lib/active_job/queue_adapter.rb (L52-L56)
2015-09-09 08:55:20 -05:00
Benjamin Fleischer
d9e76c29d5 Make Adapters registerable so they are not namespace-constrained
Changes:

- Introduce Adapter::get for use by Serializer.adapter
- Move Adapter-finding logic from Adapter::adapter_class into Adapter::get

Introduced interfaces:

- non-inherited methods
```ruby
ActiveModel::Serializer::Adapter.adapter_map     # a Hash<adapter_name, adapter_class>
ActiveModel::Serializer::Adapter.adapters        # an Array<adapter_name>
ActiveModel::Serializer::Adapter.register(name, klass) # adds an adapter to the adapter_map
ActiveModel::Serializer::Adapter.get(name_or_klass)    # raises Argument error when adapter not found
```

- Automatically register adapters when subclassing

```ruby
      def self.inherited(subclass)
        ActiveModel::Serializer::Adapter.register(subclass.to_s.demodulize, subclass)
      end
```

- Preserves subclass method `::adapter_class(adapter)`

```ruby
      def self.adapter_class(adapter)
        ActiveModel::Serializer::Adapter.get(adapter)
      end
```

- Serializer.adapter now uses `Adapter.get(config.adapter)` rather than have duplicate logic
2015-09-08 22:59:36 -05:00
Lucas Hosseini
bac812f907 Add documentation about configuration options. 2015-08-28 20:01:56 +02:00
Bruno Bacarini
b73ffe25c8 add kaminari and will_paginate examples 2015-08-20 11:31:21 -03:00
Bruno Bacarini
f85027e631 add more documentation to pagination links 2015-08-19 11:09:47 -03:00
Bruno Bacarini
2c2f948fa0 Add pagination links automatically
Pagination links will be included in your response automatically as long
as the resource is paginated using Kaminari or WillPaginate
and if you are using a JSON-API adapter. The others adapters does not have this feature.
2015-08-18 19:04:04 -03:00
Bruno Bacarini
a41d90cce4 add self to pagination links 2015-08-18 19:04:04 -03:00
Bruno Bacarini
7be25fef14 include query_parameters on pagination links as well 2015-08-18 19:04:03 -03:00
Bruno Bacarini
e62a7d6f34 return complete URIs on pagination links 2015-08-18 19:04:03 -03:00
Bruno Bacarini
acb6545c50 add documentation to pagination feature 2015-08-18 19:04:03 -03:00
T.J. Schuck
b6b3aa5f21 Fix some invalid JSON 2015-08-12 11:53:46 -04:00
João M. D. Moura
63436c73e8 minor updates and TYPOs 2015-07-16 23:29:03 -04:00
João Moura
456f9158ca removing useless exmaple lines 2015-07-16 10:18:04 -04:00
João Moura
420f7959c0 creating initial general and how to docs 2015-07-16 10:18:04 -04:00
João Moura
b0a2e9f5e2 starting initial docs structure 2015-07-16 10:18:04 -04:00