@@ -151,11 +151,11 @@ def self.expose(*args, &block)
151
151
options = merge_options ( args . last . is_a? ( Hash ) ? args . pop : { } )
152
152
153
153
if args . size > 1
154
- fail ArgumentError , 'You may not use the :as option on multi-attribute exposures.' if options [ :as ]
155
- fail ArgumentError , 'You may not use block-setting on multi-attribute exposures.' if block_given?
154
+ raise ArgumentError , 'You may not use the :as option on multi-attribute exposures.' if options [ :as ]
155
+ raise ArgumentError , 'You may not use block-setting on multi-attribute exposures.' if block_given?
156
156
end
157
157
158
- fail ArgumentError , 'You may not use block-setting when also using format_with' if block_given? && options [ :format_with ] . respond_to? ( :call )
158
+ raise ArgumentError , 'You may not use block-setting when also using format_with' if block_given? && options [ :format_with ] . respond_to? ( :call )
159
159
160
160
if block_given?
161
161
if block . parameters . any?
@@ -214,7 +214,7 @@ def self.can_unexpose?
214
214
end
215
215
216
216
def self . cannot_unexpose!
217
- fail "You cannot call 'unexpose` inside of nesting exposure!"
217
+ raise "You cannot call 'unexpose` inside of nesting exposure!"
218
218
end
219
219
220
220
# Set options that will be applied to any exposures declared inside the block.
@@ -270,7 +270,7 @@ def self.documentation
270
270
# end
271
271
#
272
272
def self . format_with ( name , &block )
273
- fail ArgumentError , 'You must pass a block for formatters' unless block_given?
273
+ raise ArgumentError , 'You must pass a block for formatters' unless block_given?
274
274
formatters [ name . to_sym ] = block
275
275
end
276
276
@@ -392,8 +392,8 @@ def self.present_collection(present_collection = false, collection_name = :items
392
392
# @option options :only [Array] all the fields that should be returned
393
393
# @option options :except [Array] all the fields that should not be returned
394
394
def self . represent ( objects , options = { } )
395
- if objects . respond_to? ( :to_ary ) && ! @present_collection
396
- root_element = root_element ( :collection_root )
395
+ if objects . respond_to? ( :to_ary ) && !@present_collection
396
+ root_element = root_element ( :collection_root )
397
397
inner = objects . to_ary . map { |object | new ( object , options . reverse_merge ( collection : true ) ) . presented }
398
398
else
399
399
objects = { @collection_name => objects } if @present_collection
@@ -485,7 +485,7 @@ def delegate_attribute(attribute)
485
485
end
486
486
end
487
487
488
- alias_method : as_json, : serializable_hash
488
+ alias as_json serializable_hash
489
489
490
490
def to_json ( options = { } )
491
491
options = options . to_h if options && options . respond_to? ( :to_h )
@@ -536,7 +536,7 @@ def self.merge_options(options)
536
536
# @param options [Hash] Exposure options.
537
537
def self . valid_options ( options )
538
538
options . keys . each do |key |
539
- fail ArgumentError , "#{ key . inspect } is not a valid option." unless OPTIONS . include? ( key )
539
+ raise ArgumentError , "#{ key . inspect } is not a valid option." unless OPTIONS . include? ( key )
540
540
end
541
541
542
542
options [ :using ] = options . delete ( :with ) if options . key? ( :with )
0 commit comments