Skip to content

Commit

Permalink
Small code clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
fredwu committed Jul 19, 2013
1 parent df16bbb commit ff06d8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/api_taster/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def add_to_buffer(params, parent_labels = [])

new_parent_labels = parent_labels.clone << label

if value.is_a?(Hash)
case value
when Hash
add_legend_to_buffer(parent_labels, label)

add_to_buffer(value, new_parent_labels)
elsif value.is_a?(Array)
when Array
value.each do |v|
if v.is_a?(Hash)
case v
when Hash
add_legend_to_buffer(parent_labels, label)

add_to_buffer(v, parent_labels.clone << "#{label}[]")
else
add_element_to_buffer(parent_labels, "#{label}[]", v)
Expand Down
6 changes: 4 additions & 2 deletions lib/api_taster/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ def normalise_routes!
next if route.app.is_a?(Sprockets::Environment)
next if route.app == ApiTaster::Engine

if (rack_app = discover_rack_app(route.app)) && rack_app.respond_to?(:routes)
rack_app = discover_rack_app(route.app)

if rack_app && rack_app.respond_to?(:routes) && rack_app.routes.respond_to?(:routes)
rack_app.routes.routes.each do |rack_route|
self.routes << normalise_route(rack_route, route.path.spec)
end if rack_app.routes.respond_to?(:routes)
end
end

next if route.verb.source.empty?
Expand Down

0 comments on commit ff06d8e

Please sign in to comment.