aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/serializers
Commit message (Collapse)AuthorAgeFilesLines
* Improve doc for :root option in as_json() [ci skip]Tenzin Chemi2019-05-131-0/+7
| | | | | | | | Remove trailing whitespace [ci skip] Reword Root value should be string [ci skip]
* 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
* Remove XML Serialization from core.Zachary Scott2015-08-071-238/+0
| | | | | | | This includes the following classes: - ActiveModel::Serializers::Xml - ActiveRecord::Serialization::XmlSerializer
* Use Active Model, not ActiveModel in plain Englishclaudiob2015-01-021-1/+1
| | | | | | | Also prevents the word "Model" from linking to the documentation of ActiveModel::Model because that's not intended. [ci skip]
* 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-242-2/+2
| | | | | | 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]
* Remove deprecated cattr_* requiresGenadi Samokovarov2013-12-031-1/+1
|
* it's xml, not jsonJohn Gesimondo2013-07-131-1/+1
| | | change docs for xml serializer to talk about xml
* 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.
* Convert ActiveModel to 1.9 hash syntax.Patrick Robertson2013-05-011-5/+5
| | | | | I also attempted to fix other styleguide violations such as { a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
* chmod -x from non-script filesAkira Matsuda2012-12-241-0/+0
|
* Only call `in_time_zone` on Time or DateTime instancesAndrew White2012-12-111-1/+6
| | | | | Both String and Date now respond to in_time_zone so we need to check if the value is a Time or a DateTime.
* Specify type of singular association during serializationSteve Klabnik2012-11-281-1/+6
| | | | | | | | | | | | When serialising a class, specify the type of any singular associations, if necessary. Rails already correctly specifies the :type of any enumerable association (e.g. a has_many association), but made no attempt to do so for non-enumerables (e.g. a has_one association). We must specify the :type of any STI association. A has_one association to a class which uses single-table inheritance is an example of this type of association. Fixes #7471
* fix AM::Serializers titles [ci skip]Francesco Rodriguez2012-10-262-2/+2
|
* AM::Serializers::Xml depends on AM::NamingFrancesco Rodriguez2012-10-261-0/+4
|
* Following the false issue reporting I did here : ↵Anthony2012-08-131-0/+4
| | | | | | | | | | | https://github.com/rails/rails/issues/6958 - Enable propagation of :skip_types, :dasherize and :camelize on included models by default - Adding the option to override this propagation on a per-include basis (:include => { :model => { :dasherize => false } } - Enough tests to prove it works - Updated activemodel CHANGELOG.md Squashed my commits
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-08-042-8/+66
|\ | | | | | | | | | | Conflicts: activemodel/lib/active_model/secure_password.rb activerecord/lib/active_record/associations/collection_proxy.rb
| * copy edits [ci skip]Vijay Dev2012-08-041-1/+1
| |
| * Fix ActiveModel::Serializers::Xml#to_xml referenceRobert Pankowecki2012-08-021-1/+1
| | | | | | | | Link to ActiveRecord::Serialization#to_xml for more details
| * update ActiveModel::Serializers documentation [ci skip]Francesco Rodriguez2012-07-302-14/+40
| |
| * 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.
* changed xml type datetime to dateTime, fixes #6328Angelo capilleri2012-05-231-1/+1
| | | | | | | | | XmlMini define the xml 'datatime', but according to http://www.w3.org/TR/xmlschema-2/#dateTime could be better change this to 'dateTime' with upper case letter 'T. So 'DateTime' and 'Time' are redefined from 'datetime' to 'dateTime' add the changing to the changelog
* Use respond_to?(:to_ary) rather than is_a?(Enumerable) to detect ↵Jon Leighton2012-05-111-1/+3
| | | | collection-thing.
* Remove Array.wrap call in ActiveModelRafael Mendonça França2012-01-061-3/+2
|
* 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-302-8/+285
| | | | | | | | | | | | | 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-232-285/+8
| | | | | | | | | | | | | 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
* to_xml should also rely on serializable hash.José Valim2011-09-181-31/+15
|
* ActiveModel support for the :include serialization optionJohn Firebaugh2011-07-171-0/+40
| | | | | | | | | | | | | | | | | | | | This commit moves support for the :include serialization option for serializing associated objects out of ActiveRecord in into ActiveModel. The following methods support the :include option: * serializable_hash * to_json * to_xml Instances must respond to methods named by the values of the :includes array (or keys of the :includes hash). If an association method returns an object that is_a?(Enumerable) (which AR has_many associations do), it is assumed to be a collection association, and its elements must respond to :serializable_hash. Otherwise it must respond to :serializable_hash itself. While here, fix #858, XmlSerializer should not singularize already singular association names.
* Enable passing root: false to #to_jsonJoe Fiorini2011-07-011-5/+17
|
* use clearer variable name in examplesVijay Dev2011-06-042-12/+12
|
* Remove extra white spaces on ActiveModel docs.Sebastian Martinez2011-05-231-2/+2
|
* Attributes with :string type should not be given the type passed in model ↵Jim Herzberg2011-05-181-1/+1
| | | | serialization options. Closes #1058
* Methods that return nil should not be considered YAMLJoshua Wehner2011-05-101-0/+1
|