@@ -185,7 +185,7 @@ def self.inherited(subclass)
185
185
# field, typically the value is a hash with two fields, type and desc.
186
186
# @option options :merge This option allows you to merge an exposed field to the root
187
187
#
188
- # rubocop:disable Metrics/LineLength
188
+ # rubocop:disable Metrics/LineLength, Style/IfUnlessModifier
189
189
def self . expose ( *args , &block )
190
190
options = merge_options ( args . last . is_a? ( Hash ) ? args . pop : { } )
191
191
@@ -196,9 +196,11 @@ def self.expose(*args, &block)
196
196
raise ArgumentError , 'You may not use block-setting on multi-attribute exposures.' if block_given?
197
197
end
198
198
199
- raise ArgumentError , 'You may not use block-setting when also using format_with' if block_given? && options [ :format_with ] . respond_to? ( :call )
200
-
201
199
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
+
202
204
if block . parameters . any?
203
205
options [ :proc ] = block
204
206
else
@@ -210,7 +212,7 @@ def self.expose(*args, &block)
210
212
@nesting_stack ||= [ ]
211
213
args . each { |attribute | build_exposure_for_attribute ( attribute , @nesting_stack , options , block ) }
212
214
end
213
- # rubocop:enable Metrics/LineLength
215
+ # rubocop:enable Metrics/LineLength, Style/IfUnlessModifier
214
216
215
217
def self . build_exposure_for_attribute ( attribute , nesting_stack , options , block )
216
218
exposure_list = nesting_stack . empty? ? root_exposures : nesting_stack . last . nested_exposures
0 commit comments