lazy_object 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lazy_object.rb +4 -4
- data/spec/lazy_object_spec.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb871ef07298953b636aa9828c59f34798fce67
|
4
|
+
data.tar.gz: 2e8e8311a5aa1d96849518eb6b8a12cea99615cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe6da338b447ba9457679df275a22a8ec07a4f8bd86849054c0e9f8c754ac4a7cf011b971fac1b88d5d316fd3a9c9c9b04373931c7ac1e60ffa0729ccb527e60
|
7
|
+
data.tar.gz: 0db17e239189b4c24fdf06614c44f578c54ccf8eef0c8a29950b60aba4b94543edb55c06fdf5e352847de299e9dcd8297e2a33c2d97caba00d97d0a8337360be
|
data/lib/lazy_object.rb
CHANGED
@@ -8,12 +8,12 @@
|
|
8
8
|
#
|
9
9
|
# lazy = LazyObject.new { VeryExpensiveObject.new } # At this point the VeryExpensiveObject hasn't been initialized yet.
|
10
10
|
# lazy.get_expensive_results(foo, bar) # Initializes VeryExpensiveObject and calls 'get_expensive_results' on it, passing in foo and bar
|
11
|
-
class LazyObject
|
12
|
-
|
11
|
+
class LazyObject < BasicObject
|
12
|
+
|
13
13
|
def self.version
|
14
|
-
'0.0.
|
14
|
+
'0.0.2'
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def initialize(&callable)
|
18
18
|
@__callable__ = callable
|
19
19
|
end
|
data/spec/lazy_object_spec.rb
CHANGED
@@ -4,12 +4,12 @@ RSpec.describe LazyObject do
|
|
4
4
|
|
5
5
|
class TargetObject
|
6
6
|
attr_accessor :value
|
7
|
-
|
7
|
+
|
8
8
|
def method_with_yield(foo)
|
9
9
|
yield foo
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
let(:lazy_object) {
|
14
14
|
LazyObject.new do
|
15
15
|
targ = TargetObject.new
|
@@ -17,12 +17,12 @@ RSpec.describe LazyObject do
|
|
17
17
|
targ
|
18
18
|
end
|
19
19
|
}
|
20
|
-
|
20
|
+
|
21
21
|
it 'should call the init block and forward methods to the target object' do
|
22
22
|
expect( lazy_object.value ).to eq(:foo)
|
23
23
|
lazy_object.value = :bar
|
24
24
|
expect( lazy_object.value ).to eq(:bar)
|
25
|
-
|
25
|
+
|
26
26
|
expect( lazy_object.method_with_yield(:baz) { |foo| "--#{foo}--" } ).to eq('--baz--')
|
27
27
|
end
|
28
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Shagall
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.4.3
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Lazily initialized object wrapper.
|