Skip to content

Commit 577186c

Browse files
committed
Partially fix Style/Next
1 parent a4cd2bc commit 577186c

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,3 @@ Style/Documentation:
4040
# Configuration parameters: Exclude.
4141
Style/FileName:
4242
Enabled: false
43-
44-
# Offense count: 1
45-
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
46-
Style/Next:
47-
Enabled: false

lib/grape_entity/entity.rb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def self.expose(*args, &block)
137137

138138
@nested_attributes ||= []
139139

140+
# rubocop:disable Style/Next
140141
args.each do |attribute|
141142
unless @nested_attributes.empty?
142143
orig_attribute = attribute.to_sym
@@ -466,22 +467,22 @@ def serializable_hash(runtime_options = {})
466467
opts = options.merge(runtime_options || {})
467468

468469
valid_exposures.each_with_object({}) do |(attribute, exposure_options), output|
469-
if should_return_attribute?(attribute, opts) && conditions_met?(exposure_options, opts)
470-
partial_output = value_for(attribute, opts)
471-
472-
output[self.class.key_for(attribute)] =
473-
if partial_output.respond_to?(:serializable_hash)
474-
partial_output.serializable_hash(runtime_options)
475-
elsif partial_output.is_a?(Array) && !partial_output.map { |o| o.respond_to?(:serializable_hash) }.include?(false)
476-
partial_output.map(&:serializable_hash)
477-
elsif partial_output.is_a?(Hash)
478-
partial_output.each do |key, value|
479-
partial_output[key] = value.serializable_hash if value.respond_to?(:serializable_hash)
480-
end
481-
else
482-
partial_output
470+
next unless should_return_attribute?(attribute, opts) && conditions_met?(exposure_options, opts)
471+
472+
partial_output = value_for(attribute, opts)
473+
474+
output[self.class.key_for(attribute)] =
475+
if partial_output.respond_to?(:serializable_hash)
476+
partial_output.serializable_hash(runtime_options)
477+
elsif partial_output.is_a?(Array) && !partial_output.map { |o| o.respond_to?(:serializable_hash) }.include?(false)
478+
partial_output.map(&:serializable_hash)
479+
elsif partial_output.is_a?(Hash)
480+
partial_output.each do |key, value|
481+
partial_output[key] = value.serializable_hash if value.respond_to?(:serializable_hash)
483482
end
484-
end
483+
else
484+
partial_output
485+
end
485486
end
486487
end
487488

0 commit comments

Comments
 (0)