Skip to content

Commit 1515b25

Browse files
anakinjLeFnord
authored andcommitted
Fix rubocop issues (#325)
1 parent 53b2502 commit 1515b25

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/grape_entity/entity.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def self.inherited(subclass)
185185
# field, typically the value is a hash with two fields, type and desc.
186186
# @option options :merge This option allows you to merge an exposed field to the root
187187
#
188-
# rubocop:disable Metrics/LineLength
188+
# rubocop:disable Metrics/LineLength, Style/IfUnlessModifier
189189
def self.expose(*args, &block)
190190
options = merge_options(args.last.is_a?(Hash) ? args.pop : {})
191191

@@ -196,9 +196,11 @@ def self.expose(*args, &block)
196196
raise ArgumentError, 'You may not use block-setting on multi-attribute exposures.' if block_given?
197197
end
198198

199-
raise ArgumentError, 'You may not use block-setting when also using format_with' if block_given? && options[:format_with].respond_to?(:call)
200-
201199
if block_given?
200+
if options[:format_with].respond_to?(:call)
201+
raise ArgumentError, 'You may not use block-setting when also using format_with'
202+
end
203+
202204
if block.parameters.any?
203205
options[:proc] = block
204206
else
@@ -210,7 +212,7 @@ def self.expose(*args, &block)
210212
@nesting_stack ||= []
211213
args.each { |attribute| build_exposure_for_attribute(attribute, @nesting_stack, options, block) }
212214
end
213-
# rubocop:enable Metrics/LineLength
215+
# rubocop:enable Metrics/LineLength, Style/IfUnlessModifier
214216

215217
def self.build_exposure_for_attribute(attribute, nesting_stack, options, block)
216218
exposure_list = nesting_stack.empty? ? root_exposures : nesting_stack.last.nested_exposures

0 commit comments

Comments
 (0)