aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/serializers/json.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix AM::Serializers::JSON#as_json method for timestampsBogdan Gusiev2017-12-211-9/+10
| | | | | According to doc the method should return non-json compatible types as strings.
* Use frozen string literal in activemodel/Kir Shatrov2017-07-161-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-2/+1
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* applies new string literal convention in activemodel/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Eliminate instance level writers for class accessorsAaron Patterson2016-01-221-1/+1
| | | | | | | | | Instance level writers can have an impact on how the Active Model / Record objects are saved. Specifically, they can be used to bypass validations. This is a problem if mass assignment protection is disabled and specific attributes are passed to the constructor. CVE-2016-0753
* Fixing documentation in JSON#from_jsonNick Veys2014-11-201-4/+4
| | | | | Commit d67b289 introduced a tiny regression in the docs for #from_json, true needs to be included when the root node is present.
* Use #model_name on instances instead of classesAmiel Martin2014-06-241-1/+1
| | | | | | This allows rails code to be more confdent when asking for a model name, instead of having to ask for the class. Rails core discussion here: https://groups.google.com/forum/#!topic/rubyonrails-core/ThSaXw9y1F8
* Adding missing backslashes in active_model files so as to avoid unwanted ↵aditya-kapoor2013-12-271-1/+1
| | | | links in rdoc [ci skip]
* Docfix: Use public interface instead of setting instance variablesRichard Livsey2013-06-071-1/+1
| | | Dynamically setting instance variables based on user input probably isn't a great idea. Better to go through the setter methods provided by attr_accessor.
* fix AM::Serializers titles [ci skip]Francesco Rodriguez2012-10-261-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-08-041-2/+36
|\ | | | | | | | | | | Conflicts: activemodel/lib/active_model/secure_password.rb activerecord/lib/active_record/associations/collection_proxy.rb
| * update ActiveModel::Serializers documentation [ci skip]Francesco Rodriguez2012-07-301-8/+10
| |
| * add documentation to ActiveModel #from_json method [ci skip]Francesco Rodriguez2012-07-301-2/+34
| |
* | load active_support/core_ext/class/attribute in active_support/railsXavier Noria2012-08-021-1/+0
|/
* small refactoring of as_json methodAngelo Capilleri2012-07-031-2/+6
| | | | with this change root has always one assignment
* Simplify AR configuration code.Jon Leighton2012-06-151-3/+2
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* change AMS::JSON.include_root_in_json default value to falseFrancesco Rodriguez2012-06-061-44/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: * Update `include_root_in_json` default value to false for default value to false for `ActiveModel::Serializers::JSON`. * Remove unnecessary change to include_root_in_json option in wrap_parameters template. * Update `as_json` documentation. * Fix JSONSerialization tests. Problem: It's confusing that AM serializers behave differently from AR, even when AR objects include AM serializers module. class User < ActiveRecord::Base; end class Person include ActiveModel::Model include ActiveModel::AttributeMethods include ActiveModel::Serializers::JSON attr_accessor :name, :age def attributes instance_values end end user.as_json => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true} # root is not included person.as_json => {"person"=>{"name"=>"Francesco", "age"=>22}} # root is included ActiveRecord::Base.include_root_in_json => false Person.include_root_in_json => true # different default values for include_root_in_json Proposal: Change the default value of AM serializers to false, update the misleading documentation and remove unnecessary change to false of include_root_in_json option with AR objects. class User < ActiveRecord::Base; end class Person include ActiveModel::Model include ActiveModel::AttributeMethods include ActiveModel::Serializers::JSON attr_accessor :name, :age def attributes instance_values end end user.as_json => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true} # root is not included person.as_json => {"name"=>"Francesco", "age"=>22} # root is not included ActiveRecord::Base.include_root_in_json => false Person.include_root_in_json => false # same behaviour, more consistent Fixes #6578.
* Support configuration on ActiveRecord::Model.Jon Leighton2011-12-281-1/+2
| | | | | | | | | | | | | | | The problem: We need to be able to specify configuration in a way that can be inherited to models that include ActiveRecord::Model. So it is no longer sufficient to put 'top level' config on ActiveRecord::Base, but we do want configuration specified on ActiveRecord::Base and descendants to continue to work. So we need something like class_attribute that can be defined on a module but that is inherited when ActiveRecord::Model is included. The solution: added ActiveModel::Configuration module which provides a config_attribute macro. It's a bit specific hence I am not putting this in Active Support or making it a 'public API' at present.
* Revert "Implement ArraySerializer and move old serialization API to a new ↵José Valim2011-11-301-3/+99
| | | | | | | | | | | | | namespace." This reverts commit 8896b4fdc8a543157cdf4dfc378607ebf6c10ab0. Conflicts: activemodel/lib/active_model.rb activemodel/lib/active_model/serializable.rb activemodel/lib/active_model/serializer.rb activemodel/test/cases/serializer_test.rb
* Implement ArraySerializer and move old serialization API to a new namespace.José Valim2011-11-231-99/+3
| | | | | | | | | | | | | The following constants were renamed: ActiveModel::Serialization => ActiveModel::Serializable ActiveModel::Serializers::JSON => ActiveModel::Serializable::JSON ActiveModel::Serializers::Xml => ActiveModel::Serializable::XML The main motivation for such a change is that `ActiveModel::Serializers::JSON` was not actually a serializer, but a module that when included allows the target to be serializable to JSON. With such changes, we were able to clean up the namespace to add true serializers as the ArraySerializer.
* Change one more place for JSON string to HashRobert Ross2011-10-041-1/+1
|
* Fix as_json doc to say what it actually returns.Robert Ross2011-10-041-1/+1
|
* Refactor AMo as_json.José Valim2011-09-231-9/+5
|
* fixed a bug with the json serialization when the class setting is set to not ↵Matt Aimonetti2011-09-221-12/+10
| | | | include the root, but an instance is serialized with the root option passed as true
* Enable passing root: false to #to_jsonJoe Fiorini2011-07-011-5/+17
|
* use clearer variable name in examplesVijay Dev2011-06-041-10/+10
|
* fixed some issues with JSON encodingJakub Suder2010-09-071-8/+6
| | | | | | | | | | | - as_json in ActiveModel should return a hash and handle :only/:except/:methods options - Array and Hash should call as_json on their elements - json methods should not modify options argument [#5374 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* to_json => as_jsonJames Miller2010-08-251-9/+9
|
* ActiveModel::Base doesn't exist, include_root_in_json is a class_attribute ↵Santiago Pastorino2010-08-101-3/+3
| | | | for the classes which includes this module
* edit pass to AMo::Serializers::JSONXavier Noria2010-08-061-9/+9
|
* adding proper markup to commentNeeraj Singh2010-07-161-2/+2
|
* Added headings to serializers.Rizwan Reza2010-06-141-2/+3
|
* Really make include_root_in_json default to true [#3770 state:resolved]José Valim2010-06-081-3/+6
|
* Active Model JSON serializer now supports custom root optionJatinder Singh2010-05-041-1/+5
| | | | | | [#4515 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Change the ActiveModel::Base.include_root_in_json default to true for Rails ↵David Heinemeier Hansson2010-01-031-5/+3
| | | | 3 [DHH]
* Break up concerns for choosing what attributes should be serialized and the ↵Joshua Peek2009-08-131-14/+4
| | | | actual serializer
* Kill AMo ivar attributes helperJoshua Peek2009-07-201-1/+0
|
* Integrate AMo JSON serializer into ARJoshua Peek2009-07-031-4/+69
|
* Initial extraction of AMo xml serializerJoshua Peek2009-07-031-15/+19
|
* Ensure JSON serializer includes model naming Joshua Peek2009-07-031-0/+2
|
* Add basic JSON serializer to AMoJoshua Peek2009-06-171-0/+38