ruby_patterns 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_patterns/version.rb +1 -1
- data/lib/ruby_patterns/virtual_proxy.rb +13 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81c0f1607976b5c1dbb445678bfb7b282e1067ed
|
4
|
+
data.tar.gz: 9ba0ef8cd6c0ea879c3ae411f7dfa1167938203d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b987cdef2560a047aa59ad691511cb1f91f2f0f87e490710784d814f728b4134f07f43566beb6f61c4d87436dd48e9da6b59067fd74dd608610108ebf8c856
|
7
|
+
data.tar.gz: 4c86028ea191e1b5cfc5c3a783b4f670210c843a7ca44ff2b169078e300f8e5eb570c6a59ae77326954525a01a63a32f0b2023d27b7a75a9b0f501097a1f38a2
|
@@ -1,41 +1,29 @@
|
|
1
1
|
module RubyPatterns
|
2
|
-
|
2
|
+
module VirtualProxy
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
def self.included(base)
|
5
|
+
base.class_eval do
|
6
|
+
attr_reader :__key
|
7
|
+
attr_accessor :__real
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
class << self
|
10
|
+
attr_accessor :loader
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
12
14
|
|
15
|
+
# @param key [Object] key used by the loader to load the real object
|
13
16
|
def initialize(key)
|
14
17
|
@__key = key
|
15
18
|
@__real = nil
|
16
|
-
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
__key
|
20
|
-
end
|
21
|
-
|
22
|
-
def inspect
|
23
|
-
"#<#{self.class.name} key=#{__key.inspect} #{__state}>"
|
24
|
-
end
|
25
|
-
|
26
|
-
def __load
|
27
|
-
raise NotImplementedError, "Subclasses must implement `__load`."
|
28
|
-
end
|
29
|
-
|
30
|
-
def __state
|
31
|
-
__real ? LOADED : GHOST
|
19
|
+
self
|
32
20
|
end
|
33
21
|
|
34
22
|
protected
|
35
23
|
|
36
24
|
def method_missing(name, *args, &block)
|
37
25
|
if __real.nil?
|
38
|
-
|
26
|
+
self.__real = self.class.loader.call(__key)
|
39
27
|
end
|
40
28
|
__real.send(name, *args, &block)
|
41
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_patterns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chandek-Stark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|