@@ -23,7 +23,7 @@ def format(new_format = nil)
23
23
namespace_inheritable ( :default_error_formatter , Grape ::ErrorFormatter . formatter_for ( new_format , { } ) )
24
24
# define a single mime type
25
25
mime_type = content_types [ new_format . to_sym ]
26
- fail Grape ::Exceptions ::MissingMimeType . new ( new_format ) unless mime_type
26
+ raise Grape ::Exceptions ::MissingMimeType . new ( new_format ) unless mime_type
27
27
namespace_stackable ( :content_types , new_format . to_sym => mime_type )
28
28
else
29
29
namespace_inheritable ( :format )
@@ -51,11 +51,11 @@ def default_error_formatter(new_formatter_name = nil)
51
51
end
52
52
53
53
def error_formatter ( format , options )
54
- if options . is_a? ( Hash ) && options . key? ( :with )
55
- formatter = options [ :with ]
56
- else
57
- formatter = options
58
- end
54
+ formatter = if options . is_a? ( Hash ) && options . key? ( :with )
55
+ options [ :with ]
56
+ else
57
+ options
58
+ end
59
59
60
60
namespace_stackable ( :error_formatters , format . to_sym => formatter )
61
61
end
@@ -106,7 +106,7 @@ def rescue_from(*args, &block)
106
106
107
107
options = args . extract_options!
108
108
if block_given? && options . key? ( :with )
109
- fail ArgumentError , 'both :with option and block cannot be passed'
109
+ raise ArgumentError , 'both :with option and block cannot be passed'
110
110
end
111
111
handler ||= extract_with ( options )
112
112
@@ -115,12 +115,12 @@ def rescue_from(*args, &block)
115
115
namespace_inheritable :all_rescue_handler , handler
116
116
else
117
117
handler_type =
118
- case options [ :rescue_subclasses ]
119
- when nil , true
120
- :rescue_handlers
121
- else
122
- :base_only_rescue_handlers
123
- end
118
+ case options [ :rescue_subclasses ]
119
+ when nil , true
120
+ :rescue_handlers
121
+ else
122
+ :base_only_rescue_handlers
123
+ end
124
124
125
125
namespace_stackable handler_type , Hash [ args . map { |arg | [ arg , handler ] } ]
126
126
end
@@ -149,7 +149,7 @@ def rescue_from(*args, &block)
149
149
# @param model_class [Class] The model class that will be represented.
150
150
# @option options [Class] :with The entity class that will represent the model.
151
151
def represent ( model_class , options )
152
- fail Grape ::Exceptions ::InvalidWithOptionForRepresent . new unless options [ :with ] && options [ :with ] . is_a? ( Class )
152
+ raise Grape ::Exceptions ::InvalidWithOptionForRepresent . new unless options [ :with ] && options [ :with ] . is_a? ( Class )
153
153
namespace_stackable ( :representations , model_class => options [ :with ] )
154
154
end
155
155
@@ -160,7 +160,7 @@ def extract_with(options)
160
160
with_option = options . delete ( :with )
161
161
return with_option if with_option . instance_of? ( Proc )
162
162
return with_option . to_sym if with_option . instance_of? ( Symbol ) || with_option . instance_of? ( String )
163
- fail ArgumentError , "with: #{ with_option . class } , expected Symbol, String or Proc"
163
+ raise ArgumentError , "with: #{ with_option . class } , expected Symbol, String or Proc"
164
164
end
165
165
end
166
166
end
0 commit comments