aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/serializers
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* copy-edits 34316d8Xavier Noria2011-02-211-7/+5
|
* Docs: Update to_xml documentation to match as_json docuemntationNicholas Rowe2011-02-201-0/+25
|
* Take into account current time zone when serializing datetime values [#6096 ↵Mike Dvorkin2010-12-091-0/+1
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Perf: refactor methods using inject when not need in activemodel.Emilio Tagua2010-09-221-4/+3
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* 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>
* ActiveModel#to_xml fix (renamed parameter).Andreas Garnæs2010-09-021-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* to_json => as_jsonJames Miller2010-08-251-9/+9
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-1/+1
| | | | 's/[ \t]*$//' -i {} \;)
* 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-142-2/+6
|
* Really make include_root_in_json default to true [#3770 state:resolved]José Valim2010-06-081-3/+6
|