@@ -86,7 +86,7 @@ def self.setup(options)
86
86
header [ 'Access-Control-Request-Method' ] = '*'
87
87
routes = @@target_class ::combined_routes [ params [ :name ] ]
88
88
routes_array = routes . map do |route |
89
- notes = route . route_notes && @@markdown ? Kramdown ::Document . new ( route . route_notes . strip_heredoc ) . to_html : route . route_notes
89
+ notes = route . route_notes && @@markdown ? Kramdown ::Document . new ( strip_heredoc ( route . route_notes ) ) . to_html : route . route_notes
90
90
http_codes = parse_http_codes route . route_http_codes
91
91
operations = {
92
92
:notes => notes ,
@@ -178,34 +178,22 @@ def parse_http_codes codes
178
178
{ :code => k , :reason => v }
179
179
end
180
180
end
181
+
182
+ def try ( *a , &b )
183
+ if a . empty? && block_given?
184
+ yield self
185
+ else
186
+ public_send ( *a , &b ) if respond_to? ( a . first )
187
+ end
188
+ end
189
+
190
+ def strip_heredoc ( string )
191
+ indent = string . scan ( /^[ \t ]*(?=\S )/ ) . min . try ( :size ) || 0
192
+ string . gsub ( /^[ \t ]{#{ indent } }/ , '' )
193
+ end
181
194
end
182
195
end
183
196
end
184
197
end
185
198
end
186
199
end
187
-
188
- class Object
189
- ##
190
- # @person ? @person.name : nil
191
- # vs
192
- # @person.try(:name)
193
- #
194
- # File activesupport/lib/active_support/core_ext/object/try.rb#L32
195
- def try ( *a , &b )
196
- if a . empty? && block_given?
197
- yield self
198
- else
199
- public_send ( *a , &b ) if respond_to? ( a . first )
200
- end
201
- end
202
- end
203
-
204
- class String
205
- # strip_heredoc from rails
206
- # File activesupport/lib/active_support/core_ext/string/strip.rb, line 22
207
- def strip_heredoc
208
- indent = scan ( /^[ \t ]*(?=\S )/ ) . min . try ( :size ) || 0
209
- gsub ( /^[ \t ]{#{ indent } }/ , '' )
210
- end
211
- end
0 commit comments