Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

memorize typo

  • Loading branch information...
commit 001c8beb4d0999a858a8b52ad511ee1251cc3517 1 parent dd41f66
@josh josh authored
View
4 actionpack/lib/action_view/renderable.rb
@@ -12,12 +12,12 @@ def self.included(base)
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
4 actionpack/lib/action_view/renderable_partial.rb
@@ -8,12 +8,12 @@ module RenderablePartial
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
12 actionpack/lib/action_view/template.rb
@@ -20,34 +20,34 @@ def initialize(template_path, load_paths = [])
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
6 activesupport/lib/active_support/memoizable.rb
@@ -5,8 +5,8 @@ def self.included(base) #:nodoc:
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 @@ def #{symbol}
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
4 activesupport/test/memoizable_test.rb
@@ -8,12 +8,12 @@ class Person
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

1 comment on commit 001c8be

@humanzz

I have previously implemented the memoize feature as method_cache plugin at http://github.com/humanzz/method_cache. But method_cache had a couple more features: in addition to caching results in instance variables it also stored the result in the cache store. It’d be great if memoize adds such feature.

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