cow_proxy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cow_proxy.rb +7 -1
- data/lib/cow_proxy/base.rb +4 -2
- data/lib/cow_proxy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a91cb4a013946161da6887f33dae43b6a6a5882
|
4
|
+
data.tar.gz: 0d86a0387ad7b39aeee5cfa0479827c3b655e7ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b418e1cfb972bffd3403e1b00b52eea84f5b53d8d5c6c165744dbb1e4b5f02037b9b8586b4e33bf6abef87bcc3a802e8db970d1ffeed1bc47da1b0346dc6277
|
7
|
+
data.tar.gz: 59b162b0c3f7939c27fc1ce6e828b3b9adf9a0892bdff552a60dff1674afa9488d9ecd7404a8e1932a07e6dde16e4e4da7d29ac4a7f930376f6941dce1174a2e
|
data/lib/cow_proxy.rb
CHANGED
@@ -41,7 +41,7 @@ module CowProxy
|
|
41
41
|
#
|
42
42
|
# @return proxy_klass
|
43
43
|
def register_proxy(klass, proxy_klass)
|
44
|
-
debug { "register proxy for #{klass} with #{proxy_klass} < #{proxy_klass.superclass}" } unless @@wrapper_classes[klass]
|
44
|
+
debug { "register proxy for #{klass} with #{proxy_klass}#{" < #{proxy_klass.superclass}" if proxy_klass}" } unless @@wrapper_classes[klass]
|
45
45
|
@@wrapper_classes[klass] ||= proxy_klass
|
46
46
|
end
|
47
47
|
|
@@ -121,6 +121,12 @@ module CowProxy
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
+
if defined? Fixnum
|
125
|
+
CowProxy.register_proxy Fixnum, nil
|
126
|
+
end
|
127
|
+
if defined? Bignum
|
128
|
+
CowProxy.register_proxy Bignum, nil
|
129
|
+
end
|
124
130
|
require 'cow_proxy/base.rb'
|
125
131
|
require 'cow_proxy/indexable.rb'
|
126
132
|
require 'cow_proxy/array.rb'
|
data/lib/cow_proxy/base.rb
CHANGED
@@ -84,8 +84,9 @@ module CowProxy
|
|
84
84
|
def __wrap__(value, inst_var = nil)
|
85
85
|
if value.frozen?
|
86
86
|
CowProxy.debug { "wrap #{value.class.name} with parent #{__getobj__.class.name}" }
|
87
|
-
|
88
|
-
|
87
|
+
wrap_klass = CowProxy.wrapper_class(value)
|
88
|
+
wrap_value = wrap_klass.new(value, self, inst_var) if wrap_klass
|
89
|
+
_instance_variable_set(inst_var, wrap_value) if inst_var && wrap_value
|
89
90
|
wrap_value
|
90
91
|
end
|
91
92
|
end
|
@@ -100,6 +101,7 @@ module CowProxy
|
|
100
101
|
def __wrapped_method__(inst_var, cow, method, *args, &block)
|
101
102
|
__wrapped_value__(inst_var, method, *args, &block)
|
102
103
|
rescue => e
|
104
|
+
CowProxy.debug { "error #{e.message} on #{__getobj__.class.name} (#{__getobj__.object_id}) #{method} #{args.inspect unless args.empty?} with#{'out' unless cow} cow" }
|
103
105
|
raise unless cow && e.message =~ /^can't modify frozen/
|
104
106
|
CowProxy.debug { "copy on write to run #{method} #{args.inspect unless args.empty?} (#{e.message})" }
|
105
107
|
__copy_on_write__
|
data/lib/cow_proxy/version.rb
CHANGED