Permalink
Browse files

Fix memoized method to have an arity of 0

  • Loading branch information...
1 parent bda21ab commit 51b90aac633b9075b08d9d5b78e84ea4b168c3bc @dkubb committed Feb 6, 2013
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/adamantium/module_methods.rb
  2. +5 −0 spec/unit/adamantium/module_methods/memoize_spec.rb
View
4 lib/adamantium/module_methods.rb
@@ -79,9 +79,9 @@ def memoize_method(method_name, freezer)
def define_memoize_method(method, freezer)
method_name = method.name.to_sym
undef_method(method_name)
- define_method(method_name) do |*args|
+ define_method(method_name) do ||
memory.fetch(method_name) do
- value = method.bind(self).call(*args)
+ value = method.bind(self).call
frozen = freezer.call(value)
store_memory(method_name, frozen)
end
View
5 spec/unit/adamantium/module_methods/memoize_spec.rb
@@ -16,6 +16,11 @@
instance.send(method).should be(instance.send(method))
end
+ it 'creates a method with an arity of 0' do
+ subject
+ object.new.method(method).arity.should be_zero
+ end
+
context 'when the initializer calls the memoized method' do
before do
method = self.method

0 comments on commit 51b90aa

Please sign in to comment.