Yehuda Katz
9da0176d2b
Merge branch 'master' of github.com:josevalim/active_model_serializers
2012-09-16 19:46:17 -07:00
Yehuda Katz
84f8c1c3d5
Merge branch 'master' of github.com:josevalim/active_model_serializers
2012-09-02 21:21:05 -07:00
Dan Gebhardt
42221a6140
define include_XXX? methods, which can be overridden to conditionally include attributes and associations
2012-08-29 09:26:41 -04:00
Dan Gebhardt
68dc57eb73
simplified the API for include_associations!() to make conditional includes cleaner
2012-08-29 07:42:23 -04:00
twinturbo
38859d1f3d
Easier to work with polymorphic interface
2012-08-25 17:39:39 +02:00
Alex Kwiatkowski & Will Bagby
754aa295ba
Return empty hash when url_options not provided
2012-08-07 12:56:58 -04:00
Jo Liss
e8f2ecebfb
Use blocks instead of eval to define methods
2012-07-26 00:28:59 +02:00
Tee Parham
663d443884
Merge branch 'array-serializer-root' of github.com:teeparham/active_model_serializers into readme-arrays
2012-07-23 13:02:04 -06:00
Tee Parham
53da0b12fd
add docs for serializing arrays
2012-07-21 15:25:41 -07:00
José Valim
ef7d475912
Merge pull request #94 from teeparham/array-serializer-root
...
Add root option to ArraySerializer
2012-07-21 00:38:18 -07:00
José Valim
6f07a0297e
Merge pull request #97 from twinturbo/include-bug
...
Include Related Bugs
2012-07-21 00:36:04 -07:00
Chris Schmitz
a6473e70c4
Fix a couple typos.
2012-07-16 09:29:12 -05:00
twinturbo
6f3b250dc9
Don't include empty polymoprhic associations
...
Take this serializer:
class TodoSerializer < ActiveModel::Serializer
root :todo, :include => true
has_one :reference, :polymorphic => true
end
A nil reference would generate this JSON:
{
"todo": { "reference": null },
"nil_classes": []
}
This commit prevents the `nil_classes` key from being added when
serializing and including nil polymoprhic associations.
2012-07-16 15:08:01 +02:00
twinturbo
486d282922
Raise error when associations cannot be included
...
include! only works when the source serializer has a root set. The
as_json method sets up some state for the include! method. If a child
association has associations with `:include => true` or `root foo,
:include => true` would cause an undefined method error for `NilClass`.
This is entirely unhelpful for the end user.
This commit raise an error when this situation occurs. It makes it clear
that it's not a problem with AMS but the serialization graph.
2012-07-16 14:18:58 +02:00
twinturbo
f01fe14972
Fix spelling mistakes
2012-07-15 11:49:36 +02:00
twinturbo
9f20fe8b36
Test passes
2012-07-15 11:49:36 +02:00
twinturbo
7e96856b87
Support serialize polymorphic id
2012-07-15 11:49:36 +02:00
twinturbo
32f8779114
Basic rooted polymorphism
2012-07-15 11:49:36 +02:00
Tee Parham
0832e42917
add class attribute :root to ArraySerializer
...
You can now set the default behavior for Array serialization in a
single place
2012-07-14 21:44:23 -06:00
twinturbo
7936e3efba
Add "scope" method
2012-07-14 14:54:23 +02:00
José Valim
3e87c6414d
Merge pull request #92 from twinturbo/query-attributes
...
Close #86
2012-07-14 04:16:07 -07:00
twinturbo
2b9cd97436
Close #86
2012-07-14 13:12:26 +02:00
José Valim
d6a68ed14f
Merge pull request #85 from pushcx/master
...
Allow setting :each_serializer in 'render :json' calls
2012-07-14 04:05:40 -07:00
Bradley Priest
f41978b8de
move array_serializer logic to active_model_serializer.rb
2012-07-10 10:23:45 +08:00
Bradley Priest
7eb2b90b7c
Automatically include ArraySerializer in ActiveRecord::Relation
...
fixes #81
2012-07-10 10:17:54 +08:00
Peter Harkins
1c820a9ba7
Allow setting the serializer for ArraySerializer.
2012-06-21 11:12:13 -05:00
Yehuda Katz
1e777ced0e
Merge branch 'master' of github.com:josevalim/active_model_serializers
2012-06-20 00:56:31 -04:00
Tee Parham
c898e3daf9
remove unncessary is_a?(Hash) check
2012-06-12 10:38:32 -07:00
Yehuda Katz
615afd125c
Allow other resource overrides
2012-06-05 23:08:01 +02:00
Yehuda Katz
00194ec0e4
Bump version
2012-06-05 10:18:59 +02:00
twinturbo
2139a6d07a
Add AS::Notifications (thx @twinturbo)
2012-06-05 10:01:53 +02:00
Yehuda Katz
6e2554d741
Merge pull request #62 from highgroove/cleanup_scope_instance_variables
...
Remove left over references to scope instance variable
2012-06-05 00:32:23 -07:00
Tee Parham
f35a2261d2
support different serializations in ArraySerializer
...
ArraySerializer can serialize arrays of Hash, ActiveModel::Serializer,
or any PORO that responds to :as_json
Each item in the array should not include its type as a root element,
since normal arrays do not do this. If you want "typed" collections,
don't use an Array.
2012-05-30 14:52:52 -06:00
José Valim
5beecd5947
Fix the build on 1.8.7 :trollface:
2012-05-17 19:28:15 +02:00
vanstee
81fddb55d3
Remove left over references to scope instance variable
2012-05-16 22:54:26 -04:00
Yehuda Katz
56b61b1532
Add URL to serializers ( closes #61 )
...
Thanks so much to @vanstee for the initial
implementation!
2012-05-16 18:35:30 -07:00
Yehuda Katz
0f1ec7a3cf
Add support for customizing fields
2012-05-16 18:13:59 -07:00
tomhuda
33d4842dcd
Prep for 0.5.0
2012-05-16 14:17:10 -07:00
ctide
f17e4cde39
Add a :root option to associations, which enables you to define what the root level key will be for the associated objects.
2012-02-22 19:35:10 -08:00
Justin Brown
19c0b35473
Fix comment.
2012-02-14 15:39:46 -05:00
Carl Lerche
46f18343cd
Add an options attr_reader in the ArraySerializer
2012-01-20 12:17:51 -08:00
tomhuda
dd32f91a25
Optimize merging associations
2012-01-16 12:12:00 -08:00
Yehuda Katz
671fc14888
remove scope as a separate concept and pass it in
...
as an option.
2012-01-11 21:16:02 -07:00
Yehuda Katz
4ad9c64e46
Allow serializers to receive instructions to
...
explicitly include or exclude specific lists of
associations.
2012-01-11 20:56:36 -07:00
Yehuda Katz
fb6af2efbb
Making include_associations! a public API
2012-01-11 20:03:48 -07:00
Yehuda Katz
573be9302d
Encapsulate more concerns in the associations.
2012-01-11 20:01:47 -07:00
Yehuda Katz
fb45aa4838
Simplify association call signature
2012-01-11 16:09:38 -07:00
Yehuda Katz
c32558248a
Cleanup
2012-01-11 16:02:23 -07:00
Yehuda Katz
d42634a1d2
Remove dead code.
2012-01-11 15:54:41 -07:00
Yehuda Katz
020b2a19df
serializable_hash should just call include!
2012-01-11 15:48:16 -07:00