adamantium 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88dae963478a72fe7589b08e88a81184179035be
|
4
|
+
data.tar.gz: 390175ab3f6de1d7a9410977a50c8601ea269f90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13be4278552ccd06271dff3e7d9be93d2e21eb4cc58d4d89aedf9e2d91c19baf95120503909e98502c8911bdf2d9a8f1bfb4fb2f12d8dcb2ee5430c0cff8e36b
|
7
|
+
data.tar.gz: a0162b86ddc7a6ad67b48307a7fea8804b4c50a7003497d724e618bcb236eac802df326563b3b01346c009173f3665bb0110739adec93941a3a78afbb7fc0e23
|
@@ -46,6 +46,35 @@ module Adamantium
|
|
46
46
|
self
|
47
47
|
end
|
48
48
|
|
49
|
+
# Test if an instance method is memoized
|
50
|
+
#
|
51
|
+
# @example
|
52
|
+
# class Foo
|
53
|
+
# include Adamantium
|
54
|
+
#
|
55
|
+
# def bar
|
56
|
+
# end
|
57
|
+
# memoize :bar
|
58
|
+
#
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# Foo.memoized?(:bar) # true
|
62
|
+
# Foo.memoized?(:baz) # false, does not care if method acutally exists
|
63
|
+
#
|
64
|
+
# @param [Symbol] name
|
65
|
+
#
|
66
|
+
# @return [true]
|
67
|
+
# if method is memoized
|
68
|
+
#
|
69
|
+
# @return [false]
|
70
|
+
# otherwise
|
71
|
+
#
|
72
|
+
# @api private
|
73
|
+
#
|
74
|
+
def memoized?(name)
|
75
|
+
memoized_methods.key?(name)
|
76
|
+
end
|
77
|
+
|
49
78
|
# Return original instance method
|
50
79
|
#
|
51
80
|
# @example
|
data/lib/adamantium/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Adamantium::ModuleMethods, '#memoized?' do
|
4
|
+
let(:object) do
|
5
|
+
Class.new do
|
6
|
+
include Adamantium
|
7
|
+
def foo
|
8
|
+
end
|
9
|
+
memoize :foo
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { object.memoized?(name) }
|
14
|
+
|
15
|
+
context 'with memoized method' do
|
16
|
+
let(:name) { :foo }
|
17
|
+
|
18
|
+
it { should be(true) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with non memoized method' do
|
22
|
+
let(:name) { :bar }
|
23
|
+
|
24
|
+
it { should be(false) }
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adamantium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kubb
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- spec/unit/adamantium/module_methods/freezer_spec.rb
|
103
103
|
- spec/unit/adamantium/module_methods/included_spec.rb
|
104
104
|
- spec/unit/adamantium/module_methods/memoize_spec.rb
|
105
|
+
- spec/unit/adamantium/module_methods/memoized_predicate_spec.rb
|
105
106
|
- spec/unit/adamantium/module_methods/original_instance_method_spec.rb
|
106
107
|
homepage: https://github.com/dkubb/adamantium
|
107
108
|
licenses: []
|
@@ -146,5 +147,6 @@ test_files:
|
|
146
147
|
- spec/unit/adamantium/module_methods/freezer_spec.rb
|
147
148
|
- spec/unit/adamantium/module_methods/included_spec.rb
|
148
149
|
- spec/unit/adamantium/module_methods/memoize_spec.rb
|
150
|
+
- spec/unit/adamantium/module_methods/memoized_predicate_spec.rb
|
149
151
|
- spec/unit/adamantium/module_methods/original_instance_method_spec.rb
|
150
152
|
has_rdoc:
|