mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Rename variable to avoid using name "include"
Better syntax highlight :)
This commit is contained in:
parent
3d04d726fd
commit
3508da50f0
1 changed files with 4 additions and 8 deletions
|
@ -9,7 +9,6 @@ module ActiveModel
|
||||||
# A minimal implementation could be:
|
# A minimal implementation could be:
|
||||||
#
|
#
|
||||||
# class Person
|
# class Person
|
||||||
#
|
|
||||||
# include ActiveModel::Serialization
|
# include ActiveModel::Serialization
|
||||||
#
|
#
|
||||||
# attr_accessor :name
|
# attr_accessor :name
|
||||||
|
@ -17,7 +16,6 @@ module ActiveModel
|
||||||
# def attributes
|
# def attributes
|
||||||
# {'name' => nil}
|
# {'name' => nil}
|
||||||
# end
|
# end
|
||||||
#
|
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Which would provide you with:
|
# Which would provide you with:
|
||||||
|
@ -41,7 +39,6 @@ module ActiveModel
|
||||||
# So a minimal implementation including XML and JSON would be:
|
# So a minimal implementation including XML and JSON would be:
|
||||||
#
|
#
|
||||||
# class Person
|
# class Person
|
||||||
#
|
|
||||||
# include ActiveModel::Serializers::JSON
|
# include ActiveModel::Serializers::JSON
|
||||||
# include ActiveModel::Serializers::Xml
|
# include ActiveModel::Serializers::Xml
|
||||||
#
|
#
|
||||||
|
@ -50,7 +47,6 @@ module ActiveModel
|
||||||
# def attributes
|
# def attributes
|
||||||
# {'name' => nil}
|
# {'name' => nil}
|
||||||
# end
|
# end
|
||||||
#
|
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Which would provide you with:
|
# Which would provide you with:
|
||||||
|
@ -124,13 +120,13 @@ module ActiveModel
|
||||||
# +records+ - the association record(s) to be serialized
|
# +records+ - the association record(s) to be serialized
|
||||||
# +opts+ - options for the association records
|
# +opts+ - options for the association records
|
||||||
def serializable_add_includes(options = {}) #:nodoc:
|
def serializable_add_includes(options = {}) #:nodoc:
|
||||||
return unless include = options[:include]
|
return unless includes = options[:include]
|
||||||
|
|
||||||
unless include.is_a?(Hash)
|
unless includes.is_a?(Hash)
|
||||||
include = Hash[Array(include).map { |n| n.is_a?(Hash) ? n.to_a.first : [n, {}] }]
|
includes = Hash[Array(includes).map { |n| n.is_a?(Hash) ? n.to_a.first : [n, {}] }]
|
||||||
end
|
end
|
||||||
|
|
||||||
include.each do |association, opts|
|
includes.each do |association, opts|
|
||||||
if records = send(association)
|
if records = send(association)
|
||||||
yield association, records, opts
|
yield association, records, opts
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue