mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Replace Field#included? with Field#excluded?.
This commit is contained in:
parent
7af198653d
commit
2696557650
@ -88,7 +88,7 @@ module ActiveModel
|
|||||||
|
|
||||||
Enumerator.new do |y|
|
Enumerator.new do |y|
|
||||||
self.class._reflections.each do |reflection|
|
self.class._reflections.each do |reflection|
|
||||||
next unless reflection.included?(self)
|
next if reflection.excluded?(self)
|
||||||
key = reflection.options.fetch(:key, reflection.name)
|
key = reflection.options.fetch(:key, reflection.name)
|
||||||
next unless include_tree.key?(key)
|
next unless include_tree.key?(key)
|
||||||
y.yield reflection.build_association(self, instance_options)
|
y.yield reflection.build_association(self, instance_options)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ module ActiveModel
|
|||||||
def attributes(requested_attrs = nil, reload = false)
|
def attributes(requested_attrs = nil, reload = false)
|
||||||
@attributes = nil if reload
|
@attributes = nil if reload
|
||||||
@attributes ||= self.class._attributes_data.each_with_object({}) do |(key, attr), hash|
|
@attributes ||= self.class._attributes_data.each_with_object({}) do |(key, attr), hash|
|
||||||
next unless attr.included?(self)
|
next if attr.excluded?(self)
|
||||||
next unless requested_attrs.nil? || requested_attrs.include?(key)
|
next unless requested_attrs.nil? || requested_attrs.include?(key)
|
||||||
hash[key] = attr.value(self)
|
hash[key] = attr.value(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -24,14 +24,14 @@ module ActiveModel
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def included?(serializer)
|
def excluded?(serializer)
|
||||||
case condition_type
|
case condition_type
|
||||||
when :if
|
when :if
|
||||||
serializer.public_send(condition)
|
|
||||||
when :unless
|
|
||||||
!serializer.public_send(condition)
|
!serializer.public_send(condition)
|
||||||
|
when :unless
|
||||||
|
serializer.public_send(condition)
|
||||||
else
|
else
|
||||||
true
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user