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|
|
||||
self.class._reflections.each do |reflection|
|
||||
next unless reflection.included?(self)
|
||||
next if reflection.excluded?(self)
|
||||
key = reflection.options.fetch(:key, reflection.name)
|
||||
next unless include_tree.key?(key)
|
||||
y.yield reflection.build_association(self, instance_options)
|
||||
|
||||
@ -17,7 +17,7 @@ module ActiveModel
|
||||
def attributes(requested_attrs = nil, reload = false)
|
||||
@attributes = nil if reload
|
||||
@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)
|
||||
hash[key] = attr.value(self)
|
||||
end
|
||||
|
||||
@ -24,14 +24,14 @@ module ActiveModel
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def included?(serializer)
|
||||
def excluded?(serializer)
|
||||
case condition_type
|
||||
when :if
|
||||
serializer.public_send(condition)
|
||||
when :unless
|
||||
!serializer.public_send(condition)
|
||||
when :unless
|
||||
serializer.public_send(condition)
|
||||
else
|
||||
true
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user