1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

memorize typo

This commit is contained in:
Joshua Peek 2008-07-14 20:02:59 -05:00
parent dd41f66af5
commit 001c8beb4d
5 changed files with 15 additions and 15 deletions

View file

@ -12,12 +12,12 @@ module ActionView
def handler
Template.handler_class_for_extension(extension)
end
memorize :handler
memoize :handler
def compiled_source
handler.new(nil).compile(self) if handler.compilable?
end
memorize :compiled_source
memoize :compiled_source
def render(view, local_assigns = {})
view._first_render ||= self

View file

@ -8,12 +8,12 @@ module ActionView
def variable_name
name.sub(/\A_/, '').to_sym
end
memorize :variable_name
memoize :variable_name
def counter_name
"#{variable_name}_counter".to_sym
end
memorize :counter_name
memoize :counter_name
def render(view, local_assigns = {})
ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do

View file

@ -20,34 +20,34 @@ module ActionView #:nodoc:
def format_and_extension
(extensions = [format, extension].compact.join(".")).blank? ? nil : extensions
end
memorize :format_and_extension
memoize :format_and_extension
def path
[base_path, [name, format, extension].compact.join('.')].compact.join('/')
end
memorize :path
memoize :path
def path_without_extension
[base_path, [name, format].compact.join('.')].compact.join('/')
end
memorize :path_without_extension
memoize :path_without_extension
def path_without_format_and_extension
[base_path, name].compact.join('/')
end
memorize :path_without_format_and_extension
memoize :path_without_format_and_extension
def source
File.read(filename)
end
memorize :source
memoize :source
def method_segment
segment = File.expand_path(filename)
segment.sub!(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}/, '') if defined?(RAILS_ROOT)
segment.gsub!(/([^a-zA-Z0-9_])/) { $1.ord }
end
memorize :method_segment
memoize :method_segment
def render_template(view, local_assigns = {})
render(view, local_assigns)

View file

@ -5,8 +5,8 @@ module ActiveSupport
end
module ClassMethods
def memorize(symbol)
original_method = "_unmemorized_#{symbol}"
def memoize(symbol)
original_method = "_unmemoized_#{symbol}"
alias_method original_method, symbol
class_eval <<-EOS, __FILE__, __LINE__
def #{symbol}
@ -22,7 +22,7 @@ module ActiveSupport
def freeze
methods.each do |method|
if m = method.to_s.match(/^_unmemorized_(.*)/)
if m = method.to_s.match(/^_unmemoized_(.*)/)
send(m[1]).freeze
end
end

View file

@ -8,12 +8,12 @@ uses_mocha 'Memoizable' do
def name
fetch_name_from_floppy
end
memorize :name
memoize :name
def age
nil
end
memorize :age
memoize :age
private
def fetch_name_from_floppy