aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-09 10:42:54 +0200
committerJosé Valim <jose.valim@gmail.com>2011-05-09 10:42:54 +0200
commit4f03e404b20b693c78b223e0c22e8233bf11e940 (patch)
tree98c80473099775240149d49ad944d7549fb22294 /actionpack
parent72a489345280964b4e4350fa6104658cd4e8da84 (diff)
downloadrails-4f03e404b20b693c78b223e0c22e8233bf11e940.tar.gz
rails-4f03e404b20b693c78b223e0c22e8233bf11e940.tar.bz2
rails-4f03e404b20b693c78b223e0c22e8233bf11e940.zip
No need for replace.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/template/resolver.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index 870897958a..c0327ecba0 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -10,17 +10,16 @@ module ActionView
attr_reader :name, :prefix, :partial, :virtual
alias_method :partial?, :partial
- def initialize(name, prefix, partial)
- @name, @prefix, @partial = name, prefix, partial
- rebuild(@name, @prefix, @partial)
+ def self.build(name, prefix, partial)
+ virtual = ""
+ virtual << "#{prefix}/" unless prefix.empty?
+ virtual << (partial ? "_#{name}" : name)
+ new name, prefix, partial, virtual
end
- def rebuild(name, prefix, partial)
- @virtual = ""
- @virtual << "#{prefix}/" unless prefix.empty?
- @virtual << (partial ? "_#{name}" : name)
-
- self.replace(@virtual)
+ def initialize(name, prefix, partial, virtual)
+ @name, @prefix, @partial = name, prefix, partial
+ super(virtual)
end
end
@@ -60,7 +59,7 @@ module ActionView
# Helpers that builds a path. Useful for building virtual paths.
def build_path(name, prefix, partial)
- Path.new(name, prefix, partial)
+ Path.build(name, prefix, partial)
end
# Handles templates caching. If a key is given and caching is on
@@ -124,7 +123,7 @@ module ActionView
private
def find_templates(name, prefix, partial, details)
- path = build_path(name, prefix, partial)
+ path = Path.build(name, prefix, partial)
extensions = Hash[EXTENSIONS.map { |ext| [ext, details[ext]] }.flatten(0)]
query(path, extensions, details[:formats])
end
@@ -147,7 +146,7 @@ module ActionView
templates
end
- # Helper for building query glob string based on resolver's pattern.
+ # Helper for building query glob string based on resolver's pattern.
def build_query(path, exts)
query = @pattern.dup
query.gsub!(/\:prefix(\/)?/, path.prefix.empty? ? "" : "#{path.prefix}\\1") # prefix can be empty...