Commit Graph

81 Commits

Author SHA1 Message Date
Bradley Priest
7eb2b90b7c Automatically include ArraySerializer in ActiveRecord::Relation
fixes #81
2012-07-10 10:17:54 +08:00
Tee Parham
c898e3daf9 remove unncessary is_a?(Hash) check 2012-06-12 10:38:32 -07:00
Andy Lindeman
47850677e9 Allows serialization_scope to be disabled with serialization_scope nil 2012-06-05 12:37:09 -04:00
Yehuda Katz
681bcf5ad7 Always add :id to attributes 2012-06-05 10:05:06 +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
Yehuda Katz
3cb74887df Merge pull request #65 from teeparham/array-root
use :root option in render :json
2012-06-05 00:31:13 -07:00
Yehuda Katz
8376a4dcd1 Merge pull request #69 from teeparham/array-serializer
Array serializer should support Hash, AMS, and PORO
2012-06-05 00:23:17 -07:00
Andy Lindeman
9a3bd4770a rails generate runs correctly under Rails 3.0.x
* Rails 3.0.x does not yield `app` to `generator` blocks in railties.
  Picks a hopefully reasonable default `Rails.application` in that case.
* Fixes #71
2012-06-01 10:08:58 -04: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
Tee Parham
dd00e218b1 use :root option in render :json
ArraySerializer can now render arrays with no root
2012-05-18 12:45:43 -06:00
José Valim
5beecd5947 Fix the build on 1.8.7 :trollface: 2012-05-17 19:28:15 +02:00
José Valim
7a093afd03 Revert "Fix build for real"
This reverts commit 43f32c868a.
2012-05-17 19:16:11 +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
43f32c868a Fix build for real 2012-05-16 18:28:24 -07:00
Yehuda Katz
c6b1cea4bc Fix the build 2012-05-16 18:26:57 -07:00
Yehuda Katz
5f4f6a3483 Merged on_load 2012-05-16 18:17:21 -07:00
Yehuda Katz
0f1ec7a3cf Add support for customizing fields 2012-05-16 18:13:59 -07:00
James A. Rosen
4c17a22207 add ActiveSupport.on_load announcement 2012-05-16 15:31:32 -07:00
tomhuda
33d4842dcd Prep for 0.5.0 2012-05-16 14:17:10 -07:00
Yehuda Katz
a2d73faa63 Generate a serializer with each new model 2012-04-30 17:18:51 -07:00
Yehuda Katz
d5d917ea56 Don't require current_user 2012-04-30 17:18:51 -07:00
Jo Liss
67d5eefd8e Simplify code 2012-04-17 15:54:34 +02: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
Carl Lerche
4e8a2af1ec Allow passing in the serializer class from the render method 2012-01-20 12:17:37 -08:00
tomhuda
dd32f91a25 Optimize merging associations 2012-01-16 12:12:00 -08:00
Yehuda Katz
55647286da Make it possible to supply default serializer
options in a controller.
2012-01-11 21:30:10 -07: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
Yehuda Katz
5a8682b4e6 Make it easier to look up associations by name. 2012-01-11 15:36:17 -07:00
Yehuda Katz
b22eebf569 More refactoring:
* Changed associations to be classes
* remove @hash and always use @options[:hash]
* pass serializer options down to child serializers
2012-01-11 15:28:49 -07:00
Yehuda Katz
72b8213bee If an existing association exists, use it to
get the value if none was provided.
2012-01-11 13:06:19 -07:00
Yehuda Katz
dd0b56c748 HasOne associations work 2012-01-11 12:26:49 -07:00
Yehuda Katz
f9d0259340 Start cleaning up serializers to support
include/exclude functionality.

This process involves building a few lower-level
primitives so not as much logic is hardcoded in
monolithic helper methods.
2012-01-11 12:18:18 -07:00
Yehuda Katz
ab1a4074ba Revert polymorphism 2012-01-11 11:13:32 -07:00
Yehuda Katz
c083774f9c Check for respond_to? :to_ary instead of being
an Array.
2012-01-10 20:53:29 -07:00
Yehuda Katz
4965558d27 with ember :ids, :include => true, has_one
associations should include plural versions at
the root, not singular ones.
2012-01-10 15:16:00 -07:00
José Valim
1470e3a3f4 Merge pull request #24 from Adman65/polymorphic-associations
Polymorphic associations
2012-01-03 03:40:56 -08:00
adman65
09bb41fbdb Add test cases for nil polymorphic associations 2012-01-03 13:37:39 +02:00
adman65
54d3f2edf0 Add polymorphic key to utility method 2012-01-03 13:26:47 +02:00
Yehuda Katz
87d2d77ac8 In a controller, the current controller name should be the default root for collections 2012-01-01 16:01:59 -08:00