simple-lazy 1.0.1 → 1.0.2
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 +4 -4
- data/lib/simple/lazy.rb +9 -1
- data/test/simple/lazy_test.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53c48791475aee5999bdb60f0739cf2f2741a5ab60584086aff63f0b42754a26
|
4
|
+
data.tar.gz: e5f766ae15390978a13194be2d61a1f2da2824c91a0db60b87e237706d3fa6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e54048bda40b9642143b3dbcaa22752e933aa78aa1ada6db6e281054317249f2e7ec0660ccfd296df623af410c83b7bc9cfe3d482aae9e1a45057c17218b39
|
7
|
+
data.tar.gz: c73ffd108b7a4455764f35f9c574faecf5da8f870b413cec29beb2115f3c3d4cea3cb522cba6eae25462eb925809627ab44ffa8403ef196c278ca210608bfa3e
|
data/lib/simple/lazy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Simple
|
2
2
|
class Lazy
|
3
|
-
VERSION = "1.0.
|
3
|
+
VERSION = "1.0.2"
|
4
4
|
|
5
5
|
attr_reader :value
|
6
6
|
|
@@ -27,6 +27,14 @@ module Simple
|
|
27
27
|
cached.public_send(method, *args, &block)
|
28
28
|
end
|
29
29
|
|
30
|
+
def respond_to_missing?(method, include_private = false)
|
31
|
+
cached.respond_to?(method) || super
|
32
|
+
end
|
33
|
+
|
34
|
+
def methods
|
35
|
+
methods + cached.methods
|
36
|
+
end
|
37
|
+
|
30
38
|
def cached
|
31
39
|
unless @is_cached
|
32
40
|
@cached = @block.call(value)
|
data/test/simple/lazy_test.rb
CHANGED
@@ -45,4 +45,10 @@ class TestSimpleLazy < Minitest::Test
|
|
45
45
|
assert_equal("", lazy.to_s)
|
46
46
|
assert_equal(true, lazy.cached?)
|
47
47
|
end
|
48
|
+
|
49
|
+
def test_6
|
50
|
+
lazy = Simple::Lazy.new(1) { 2 }
|
51
|
+
assert_equal(true, lazy.respond_to?(:to_i))
|
52
|
+
assert_equal(false, lazy.respond_to?(:to_something_else))
|
53
|
+
end
|
48
54
|
end
|