Commit Graph

79 Commits

Author SHA1 Message Date
大野峻典
ce8dd36633 Add documentation for root (#1959) 2016-11-01 19:25:52 +01:00
Mario Olivio Flores
1899437566 Add info on setting polymorphic serializers (#1906)
While this same document provides details on how to override the
serializer_for, not all users will realize this could be used to set the
sterilizers for polymorphic relationships.  This change just adds a link
to that documentation and makes that point obvious.
2016-09-07 15:22:08 -04:00
Benjamin Fleischer
d34069b6ae Merge pull request #1799 from ScottKbka/patch-1
Update rendering.md
2016-08-31 16:18:47 -05:00
Ian C. Anderson
2423ca4999 Support key transformation for Attributes adapter (#1889)
The `:attributes` adapter is the default one, but it did not support
key transformation. This was very surprising behavior, since the
"Configuration Options" page in the guides didn't mention that this
behavior was not supported by the attributes adapter.

This commit adds key transform support to the attributes adapter, and
adds documentation about the default transform for the attributes
adapter (which is `:unaltered`).

This commit also handles arrays when transforming keys, which was needed
in the case where you're serializing a collection with the Attributes
adapter. With the JSON adapter, it was always guaranteed to pass a hash
to the KeyTransform functions because of the top-level key. Since there
is no top-level key for the Attributes adapter, the return value could
be an array.
2016-08-25 15:21:27 -04:00
Scott Kobewka
7178b9de7b Documenting Adapter. Fixing typo in association.rb documentation. 2016-08-17 20:24:36 -04:00
L. Preston Sego III
6de3f31b6e Namespace separator setting for json-api and tests (#1874)
Adds jsonapi_namespace_separator configuration

Also:

* Enable getting type from record class without serializer

Needs Followup:

- https://github.com/rails-api/active_model_serializers/pull/1874#discussion_r74607042 
- https://github.com/rails-api/active_model_serializers/pull/1874#discussion_r74607734
2016-08-12 12:54:42 -05:00
Edward Andrews-Hodgson
be8f136d15 Add warning in caching documentation 2016-08-04 17:17:00 +01:00
bluehallu
4ff33a7ad1 Fix typo (#1855) 2016-07-24 15:49:38 -04:00
Yogesh Khater
156dc232ce Add doc for setting conditional serialization_scope 2016-06-30 17:14:58 +05:30
Luiz Eduardo Kowalski
d27b21a733 Add docs for the fields option 2016-06-24 07:09:21 +02:00
Scott Kobewka
43b6bae7fe Fixing typo in Serializers guide for including a block after 2016-06-14 14:27:23 -04:00
Benjamin Fleischer
5017bb7f2e Fix spelling
```
cat <<  'EOF' > .git/hooks/pre-push

bundle exec rake rubocop

if command -v misspell >/dev/null; then
  misspell  -w -error -source=text {app,config,lib,spec,test,docs,bin}/**/* 2>/dev/null
fi

EOF
chmod +x .git/hooks/pre-push
```
2016-06-09 03:41:01 -05:00
Spencer Oberstadt
998ca55e3d Fix docs for deserialization (#1768)
I found in the tests that deserialization expects relationships to be under a `relationships` key.
https://github.com/rails-api/active_model_serializers/blob/master/test/action_controller/json_api/deserialization_test.rb#L68
2016-06-01 16:50:15 -04:00
Yohan Robert
b8af2892f7 [skip ci] Fix root key documentation (#1761)
The current documentation stated that it was not possible to override
the root key for the JSON adapter. This was removed from the
documentation and it now links the useful documentation pages.
2016-05-31 13:30:47 -06:00
Ben Mills
f2cb497fe3 Add key transform performance note to docs (#1753) 2016-05-26 16:19:19 -04:00
Ben Woosley
8c18d18cdb Add default_includes configuration
This is useful to set application-wide default behavior - e.g. in
previous versions of AMS the default behavior was to serialize the
full object graph by default - equivalent to the '**' include tree.

Currently just the global setting, but I think this could also work
on a per-serializer basis, with more attention.
2016-05-26 00:16:14 +00:00
André Aubin
efdee6041b Adding documentation on conditional attributes
Adding documentation and short example ([from this pull request](https://github.com/rails-api/active_model_serializers/pull/1403)) on conditional attributes.

Adding lambda literal notation and example.

Adding lambda literal notation and example, and fixing typo.

Removing PR reminder

Adding Changelog entry

Moving CHANGELOG entry under master (unreleased)

Use option instead of parameter
2016-05-20 00:47:53 +02:00
cgmckeever
ec15fa9de3 Adds documentation for overriding default serializer based on conditions (#1730)
suggested changes

update changelog
2016-05-17 15:28:54 -04:00
cgmckeever
bbed12864d adds polymorphic option to association definition which includes association type in serializer
regen gemlock

regen gemlock

better variable naming

rubocop fixes

adds to changelog

adds empty relationship and has_many polymorph tests

indent

test cleaning

-rubocop

rubocop

rubocop

rubocop

changelog

remove silly .DS

fix roque failure

fix
2016-05-17 12:30:59 -05:00
Fumiaki MATSUSHIMA
aa087a22b5 String/Lambda support for conditional attributes/associations 2016-04-26 21:37:25 +09:00
Lucas Hosseini
4c0e2dcb28 Fix example in docs/general/deserialization.md. 2016-04-18 01:04:50 +02:00
Michał Zając
dcc7af925d Update serializers.md 2016-04-11 14:52:07 +02:00
Benjamin Fleischer
afe3c93807 Add more association documentation (#1635)
[DOC] Add more association documentation
2016-04-10 12:44:37 -05:00
Ben Mills
3498647d1a Apply key transforms to keys referenced in values 2016-04-04 10:16:04 -06:00
Chris Peters
dba85f2720 #1594 - Document generator's auto-extending of (if it exists) 2016-04-02 13:18:07 -04:00
Krzysztof Rybka
37e0fdb0ee Remove wrong quoting in serializers guide 2016-03-31 14:56:07 +02:00
Benjamin Fleischer
fa7b3afbfd Prefer explicitly yielding the serializer, per groyoh 2016-03-30 14:01:28 -05:00
Yohan Robert
21cb896802 Move SerializableResource to ActiveModelSerializers namespace
Ref. https://github.com/rails-api/active_model_serializers/pull/1310
2016-03-30 11:33:04 +02:00
Ben Mills
bfff46b66e Add output examples to Adapters docs 2016-03-17 14:07:32 -06:00
Jeffrey Wan
297e1f7e9d Update docs regarding overriding the root key 2016-03-17 10:54:22 -06:00
L. Preston Sego III
88d4fe5b5e Merge pull request #1431 from beauby/deserialization-docs
Add docs for deserialization.
2016-03-17 12:48:55 -04:00
L. Preston Sego III
586ff09cc5 Added more detailed examples to deserialization.md from json_api/deserialization.rb 2016-03-17 07:58:51 -04:00
Ben Mills
9e992358d8 Merge pull request #1574 from remear/key-casing
Provide key transformation
2016-03-15 13:42:24 -06:00
Marc Garreau
045fa9bc07 Adds polymorphic tests and documentation 2016-03-15 13:09:59 -06:00
Ben Mills
c533d1a7fe Provide key case translation 2016-03-15 12:21:10 -06:00
Krzysztof Rybka
7c3f0ec6af Remove wrong quoting in serializers guide 2016-03-14 15:00:46 +01:00
Benjamin Fleischer
26b089c881 Add serialization_scope example [ci skip] 2016-03-12 19:59:43 -06:00
Ben Mills
4219844c12 Add resource-level meta docs. Update top-level meta docs. 2016-03-08 20:47:22 -07:00
Ben Mills
cc10928472 Provide Rails url_helpers via SerializationContext 2016-03-07 10:40:34 -07: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
5b953ff40f Address concerns from #1018 commit c59668e 2016-02-08 17:55:15 -06: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
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