adamantium 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a106380b26c0c580838bdca91828157a4d78af22
4
- data.tar.gz: 2428edceb354531cd1df081e47108abcfe1ba626
3
+ metadata.gz: 88dae963478a72fe7589b08e88a81184179035be
4
+ data.tar.gz: 390175ab3f6de1d7a9410977a50c8601ea269f90
5
5
  SHA512:
6
- metadata.gz: 94ab91bd30dc4764feaee048f7b9839e03fbcc24c5a725a4ac47feca64fc6b97b33c5f6392032faa9db8ac1cc484d61acae9615c21905f030a85d7e1f3372b5b
7
- data.tar.gz: 487094b783776a59126ca78820f69a996f890ca579b4b511aeb951f50d525454c8c4a785ae2b98c26faf53c741b2a1df0ff7d9e9788f74cbc97943eaf5863b7e
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
@@ -3,6 +3,6 @@
3
3
  module Adamantium
4
4
 
5
5
  # Released gem version
6
- VERSION = '0.0.9'.freeze
6
+ VERSION = '0.0.10'.freeze
7
7
 
8
8
  end # module Adamantium
@@ -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.9
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: