Commit Graph

432 Commits

Author SHA1 Message Date
Vladislav
ccc9c2c696 Update README.md
Spelling and murkup mistakes fixed.
2013-01-06 13:31:35 +04:00
Blake Watters
b0aced9ea2 Add support for specifying the serializer for an association as a String.
This enables the deferral of the resolution of the serializer class to prevent NameError exceptions due to reference cycles between serializer classes.
2013-01-05 23:49:28 -05:00
Steve Klabnik
e3bfd07ac4 Merge pull request #161 from kevins90/fix_attr_name_as_serializer_underscored_prefix
Fix serialization of attribute whose name matches the serializer prefix underscored
2013-01-05 14:09:15 -08:00
Steve Klabnik
7f87c9b3f2 Merge pull request #169 from dgeb/embed-with-id-suffix
Update foreign key naming conventions - fixes #158
2012-12-21 22:49:06 -08:00
Steve Klabnik
b5b392395a Merge pull request #177 from hmsimple/fix-id-methods
use _ids method instead of pluck to embed ids
2012-12-21 14:46:17 -08:00
Nick Ragaz
be005c6964 use _ids method instead of pluck 2012-12-21 17:35:16 -05:00
Dan Gebhardt
3b1d2faf51 Append an _id or _ids suffix to associations' keys. Embed objects in root according to their serializers' names.
An `_id` suffix will be appended to the name of HasOne associations, while `_ids` will be appended to the singularized name of HasMany associations. Association keys can still be overridden with the `key` option.

Furthermore, objects embedded in the root are now by default named according to their serializer, instead of the key used for their associations.
2012-12-21 15:14:50 -05:00
Carlos Antonio da Silva
a74fc6c8db Merge pull request #175 from jlecour/deducted_serializer_test
Test : use a deducted serializer on non-ActiveRecord models
2012-12-21 04:11:24 -08:00
Steve Klabnik
89660d1c5d Merge pull request #176 from hmsimple/id-methods
Use pluck(:id) or _id methods instead of associated objects
2012-12-20 11:55:57 -08:00
Steve Klabnik
09dbace891 Merge pull request #173 from jacortinas/document_ams_support_include
Document adding serializer support to normal Ruby classes and other ORM's.
2012-12-20 11:40:51 -08:00
Nick Ragaz
1eb3c27a50 remove debugging code 2012-12-20 13:29:37 -05:00
Nick Ragaz
a854c1b9dc use id methods 2012-12-20 13:21:37 -05:00
Jérémy Lecour
c68a18630b Test : use a deducted serializer on non-ActiveRecord models 2012-12-20 17:06:19 +01:00
Jose Angel Cortinas
d0ab0ccc97 Take a stab at documenting AMS support.
Specifically when used in objects that are not ActiveRecord objects.
2012-12-17 17:17:32 -06:00
Vladislav
fde724e210 Added description of default_serializer_options
In example it's used to set up root: false for controller
2012-12-15 01:35:52 +04:00
Matt Rogish
72652ce37e Adding info to the readme on how to specify the type, adding an additional
test to cover a computed property without a type
2012-12-11 10:33:17 -05:00
Matt Rogish
25c564bd6f Adding optional type for attributes 2012-12-10 19:58:58 -05:00
Steve Klabnik
6780cd3df5 Merge pull request #138 from tchak/meta
Meta object
2012-12-10 10:48:39 -08:00
Steve Klabnik
3fdd4bb71d Merge pull request #114 from chancancode/fix_default_serializer_options
Fix default_serializer_options, closes #112 & #113
2012-12-03 03:22:00 -08:00
Godfrey Chan
6581f8ce41 Fix default_serializer_options, closes #112 & #113
Allow options such as :serializer, :scope, :root etc to be set via
default_serializer_options and allow the inline options to override such
defaults.
2012-12-03 03:09:58 -08:00
Steve Klabnik
e79fe399a5 Merge pull request #166 from gabetax/initializer-documentation
Update documentation to use ActiveSupport.on_load to disable root
2012-11-30 12:01:41 -08:00
Gabe Martin-Dempesy
0e02e79af8 Update documentation to use ActiveSupport.on_load to disable root 2012-11-30 13:47:09 -06:00
Carlos Antonio da Silva
3c9831dc56 Merge pull request #163 from frodsan/yapr_travis
Yet Another PR on Travis
2012-11-25 14:53:48 -08:00
Francesco Rodriguez
0103eee04f add ruby-head to travis.yml 2012-11-25 17:31:15 -05:00
Francesco Rodriguez
6c88455587 use proper tags for jruby on travis 2012-11-25 17:30:10 -05:00
Rafael Mendonça França
470d65d12f Merge pull request #162 from frodsan/fix_edge_tests
Fix failing tests on Rails master
2012-11-25 12:36:33 -08:00
Francesco Rodriguez
6e2988eec7 no need to allow failures 2012-11-25 14:59:25 -05:00
Francesco Rodriguez
7a0092ab32 move gemfiles/Gemfile.edge to root 2012-11-25 14:58:59 -05:00
Francesco Rodriguez
6be6599bb7 Fix failing tests on Rails master 2012-11-25 14:56:58 -05:00
Kevin Tham
14a35ab2f8 Remove unneeded method aliasing of attribute reader: object, with the underscored class name of serializer, to fix issue where a model's attribute name matches that of the underscored prefix of the serializer 2012-11-25 00:17:17 -08:00
Jo Liss
720f1dabf8 Merge pull request #160 from byroot/143-throw-decriptive-error
[PR] Throw a descriptive error if attempting to serialize an array with Serializer not ArraySerializer
2012-11-23 06:48:41 -08:00
Jean Boussier
06e8218193 Throw a descriptive error if attempting to serialize an array with Serializer not ArraySerializer #143 2012-11-22 23:27:18 -05:00
Jo Liss
2fc083a1fe Merge pull request #117 from joliss/computed-attributes
Make schema not crash on computed attributes & associations
2012-11-22 08:31:18 -08:00
tchak
a71698d5bb Add support for meta key
Test for meta_key serialization
2012-11-22 13:44:59 +01:00
Rafael Mendonça França
6b88f1b6ef Merge pull request #157 from frodsan/fix_readme
update travis link [ci skip]
2012-11-20 17:38:17 -08:00
Francesco Rodriguez
d3b02ab8b3 update travis link [ci skip] 2012-11-20 20:37:23 -05:00
Rafael Mendonça França
5d839e5725 Merge pull request #156 from frodsan/fix_rbx_travis_tag
Update travis.yml to use the right Rubinius versions
2012-11-20 15:57:34 -08:00
Francesco Rodriguez
584bbc9151 Update travis.yml to use the right Rubinius versions 2012-11-20 18:54:59 -05:00
Rafael Mendonça França
f3159dfd0d Merge pull request #155 from teeparham/array_serializer_test
Move ArraySerializer tests and test fakes into separate files
2012-11-20 10:47:56 -08:00
Tee Parham
2cb7a41780 move ArraySerializer tests into separate file 2012-11-20 10:58:16 -07:00
Tee Parham
f47a10cadc move test fakes to separate file 2012-11-20 10:44:23 -07:00
Steve Klabnik
5d45f5ec6f Merge pull request #152 from samnang/setting_root
Fixed root(false) vs root=false inconsistency
2012-11-20 02:36:09 -08:00
Samnang Chhun
96ce310595 Add alias_method ActiveModel::Serializer.root= to be consistency with ActiveModel::ArraySerializer 2012-11-20 00:29:00 +07:00
Jo Liss
6ca430cec3 Merge pull request #150 from kurko/fixes_new_repo_readme
Fixes repo URL in the README's installation instructions
2012-11-18 19:23:43 -08:00
Alexandre de Oliveira
3fd7d6ae2f Fixes repo URL in the README's installation instructions
When the gem moved over to github.com/rails_api/, the README instructions
were still pointing to github.com/josevalim/.
2012-11-19 01:05:00 -02:00
Jo Liss
538b0c0916 Make schema not crash on computed associations
We pick nil here as well.
2012-10-31 20:07:08 +01:00
Jo Liss
6281a9149e Make schema not crash on computed attributes
We do not know the type for computed attributes, so we pick nil.

Perhaps at some point we might add a :type option for attributes (or
not), but in any case it's important to not crash when there are
computed attributes.
2012-10-31 20:07:08 +01:00
Yehuda Katz
9f5e1b1776 Merge pull request #142 from joliss/sideloading-complexity
When objects are sideloaded multiple times, serialize them only once
2012-10-31 12:04:47 -07:00
Jo Liss
c767d7f5e4 Remove newly-redundant OrderedSet 2012-10-29 23:15:39 +01:00
Jo Liss
ee3cec3d0c When objects are sideloaded multiple times, serialize them only once
To achieve this, we make the following change when sideloading: Instead
of serializing associations and discarding duplicate *hashes*, we
memorize the *objects* (records) that we have already serialized, and
only serialize those that are new.

This change is mostly transparent, and brings down serialization time
from 3.1 seconds to 1.0 seconds on my set of sample data.

There is one change in the behavior: If you sideload the same object
multiple times, and it yields different hashes, like so:

    embed :ids, include: true
    has_many :comments
    has_many :recent_comments, root: comments, serializer: CommentShortSerializer

then previously, it would be included multiple times, whereas now, the
first hash wins. (I haven't actually tested this.) I don't know that
either option is preferable. It's not covered by the test suite, and I
think it's an edge case that is OK to ignore entirely.
2012-10-29 23:15:32 +01:00