mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Merge pull request #282 from morgoth/unify-calling-include_attribute
Unify way of calling include_attribute? in attibutes and association methods
This commit is contained in:
commit
2f21e77e90
@ -103,10 +103,10 @@ module ActiveModel
|
|||||||
define_include_method attr
|
define_include_method attr
|
||||||
|
|
||||||
# protect inheritance chains and open classes
|
# protect inheritance chains and open classes
|
||||||
# if a serializer inherits from another OR
|
# if a serializer inherits from another OR
|
||||||
# attributes are added later in a classes lifecycle
|
# attributes are added later in a classes lifecycle
|
||||||
# poison the cache
|
# poison the cache
|
||||||
define_method :_fast_attributes do
|
define_method :_fast_attributes do
|
||||||
raise NameError
|
raise NameError
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ module ActiveModel
|
|||||||
|
|
||||||
def root_name
|
def root_name
|
||||||
return false if self._root == false
|
return false if self._root == false
|
||||||
|
|
||||||
class_name = self.class.name.demodulize.underscore.sub(/_serializer$/, '').to_sym unless self.class.name.blank?
|
class_name = self.class.name.demodulize.underscore.sub(/_serializer$/, '').to_sym unless self.class.name.blank?
|
||||||
self._root || class_name
|
self._root || class_name
|
||||||
end
|
end
|
||||||
@ -451,7 +451,7 @@ module ActiveModel
|
|||||||
method << " h = {}\n"
|
method << " h = {}\n"
|
||||||
|
|
||||||
_attributes.each do |name,key|
|
_attributes.each do |name,key|
|
||||||
method << " h[:\"#{key}\"] = read_attribute_for_serialization(:\"#{name}\") if send #{INCLUDE_METHODS[name].inspect}\n"
|
method << " h[:\"#{key}\"] = read_attribute_for_serialization(:\"#{name}\") if include?(:\"#{name}\")\n"
|
||||||
end
|
end
|
||||||
method << " h\nend"
|
method << " h\nend"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user