Skip to content
Browse files

refactor cache building method

  • Loading branch information...
1 parent 88a9296 commit b79be7ae6940a0319bcb81cdbb9fffee5c29a8f4 @tenderlove tenderlove committed Aug 29, 2012
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/journey/formatter.rb
View
12 lib/journey/formatter.rb
@@ -112,16 +112,14 @@ def verify_required_parts! route, parts
end
def build_cache
- kash = {}
+ root = { :___routes => [] }
routes.each_with_index do |route, i|
- money = kash
- route.required_defaults.each do |tuple|
- hash = (money[tuple] ||= {})
- money = hash
+ leaf = route.required_defaults.inject(root) do |h, tuple|
+ h[tuple] ||= {}
end
- (money[:___routes] ||= []) << [i, route]
+ (leaf[:___routes] ||= []) << [i, route]
end
- kash
+ root
end
def cache

0 comments on commit b79be7a

Please sign in to comment.
Something went wrong with that request. Please try again.