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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e8ad0e3e6d0a5203dc430bac388c6a5d689b1ae
4
- data.tar.gz: fc9e8dfbb9a49f91bfb8df115488b268adab9b79
3
+ metadata.gz: 81c0f1607976b5c1dbb445678bfb7b282e1067ed
4
+ data.tar.gz: 9ba0ef8cd6c0ea879c3ae411f7dfa1167938203d
5
5
  SHA512:
6
- metadata.gz: 000d8d909362f45246c67e86ae2f672fa07a9af431c299de93bd316f7e90b353e3198cadec0aff3614513e30fed962be045dfe6c8cb077122c2c7bcd40c185f4
7
- data.tar.gz: d86def70c4d15b82ff9edac7a3cb1f8d3949ec525e4c91e9c56a8fd4d67737205f4e6aadf9d3e33e405bb6c8d234b5e2a3ecd50be81d58af97c2e6c95870a8cf
6
+ metadata.gz: a4b987cdef2560a047aa59ad691511cb1f91f2f0f87e490710784d814f728b4134f07f43566beb6f61c4d87436dd48e9da6b59067fd74dd608610108ebf8c856
7
+ data.tar.gz: 4c86028ea191e1b5cfc5c3a783b4f670210c843a7ca44ff2b169078e300f8e5eb570c6a59ae77326954525a01a63a32f0b2023d27b7a75a9b0f501097a1f38a2
@@ -1,3 +1,3 @@
1
1
  module RubyPatterns
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,41 +1,29 @@
1
1
  module RubyPatterns
2
- class VirtualProxy
2
+ module VirtualProxy
3
3
 
4
- attr_reader :__key
5
- private :__key
4
+ def self.included(base)
5
+ base.class_eval do
6
+ attr_reader :__key
7
+ attr_accessor :__real
6
8
 
7
- attr_accessor :__real
8
- private :__real=, :__real
9
-
10
- GHOST = "GHOST"
11
- LOADED = "LOADED"
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
- end
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
- __load
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.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-08 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler