Skip to content

Commit 2696557

Browse files
committed
Replace Field#included? with Field#excluded?.
1 parent 7af1986 commit 2696557

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/active_model/serializer/associations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def associations(include_tree = DEFAULT_INCLUDE_TREE)
8888

8989
Enumerator.new do |y|
9090
self.class._reflections.each do |reflection|
91-
next unless reflection.included?(self)
91+
next if reflection.excluded?(self)
9292
key = reflection.options.fetch(:key, reflection.name)
9393
next unless include_tree.key?(key)
9494
y.yield reflection.build_association(self, instance_options)

lib/active_model/serializer/attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Attributes
1717
def attributes(requested_attrs = nil, reload = false)
1818
@attributes = nil if reload
1919
@attributes ||= self.class._attributes_data.each_with_object({}) do |(key, attr), hash|
20-
next unless attr.included?(self)
20+
next if attr.excluded?(self)
2121
next unless requested_attrs.nil? || requested_attrs.include?(key)
2222
hash[key] = attr.value(self)
2323
end

lib/active_model/serializer/field.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def value(serializer)
2424
#
2525
# @api private
2626
#
27-
def included?(serializer)
27+
def excluded?(serializer)
2828
case condition_type
2929
when :if
30-
serializer.public_send(condition)
31-
when :unless
3230
!serializer.public_send(condition)
31+
when :unless
32+
serializer.public_send(condition)
3333
else
34-
true
34+
false
3535
end
3636
end
3737

0 commit comments

Comments
 (0)