Permalink
Browse files

caching required parts and regular parts

  • Loading branch information...
1 parent 69f1e19 commit 051432542210d42060c8d5eb04d2540fe908158c @tenderlove tenderlove committed Aug 16, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/journey/route.rb
View
@@ -18,6 +18,8 @@ def initialize app, path, constraints, defaults = {}
@constraints.keep_if { |_,v| Regexp === v || String === v }
@defaults = defaults
@required_defaults = nil
+ @required_parts = nil
+ @parts = nil
end
def required_keys
@@ -68,7 +70,7 @@ def visit_SYMBOL node
end
def parts
- path.names.map { |n| n.to_sym }
+ @parts ||= path.names.map { |n| n.to_sym }
end
def format path_options
@@ -88,7 +90,7 @@ def optional_parts
end
def required_parts
- path.required_names.map { |n| n.to_sym }
+ @required_parts ||= path.required_names.map { |n| n.to_sym }
end
def required_defaults

0 comments on commit 0514325

Please sign in to comment.