class-cattr 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/.version +1 -1
- data/lib/lib/base.rb +10 -6
- 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: e5b8ee894264312e37f4ab8c50c9b968f78daa42bf099cb83a10bea0110074da
|
4
|
+
data.tar.gz: 71287dd412409772d3ca15f9260da2b9bdf419164644088d13552f9d5db4ad54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88948b3e2d2a34b3d153dcdbafcf054159c5b01d55ce2f6c7b4212d39cc5256a1f1b53507eec4dcc41bfe3a903e9d22f16162be492040c56f59179c025c52901
|
7
|
+
data.tar.gz: 786b42b9e22806b4aa3ab92d45f0706f613c1c1439e6b9dd7c06dedd4fdfcd9775bcb26732acb183e21b6ec2d176d2f81fafdad48f9a90c16b0d418209981702
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/lib/base.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class Class
|
2
|
-
def cattr name = nil,
|
3
|
-
|
2
|
+
def cattr name = nil, value = nil, &block
|
3
|
+
return CattrProxy.new(self) unless name
|
4
|
+
|
5
|
+
if !value.nil? || block
|
4
6
|
define_singleton_method(name) do |arg = :_nil|
|
5
7
|
if arg == :_nil
|
6
8
|
CattrProxy.new(self).send(name)
|
@@ -8,12 +10,14 @@ class Class
|
|
8
10
|
CattrProxy.new(self).send('%s=' % name, arg)
|
9
11
|
end
|
10
12
|
end
|
11
|
-
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
if !value.nil?
|
15
|
+
CattrProxy.new(self).send('%s=' % name, value)
|
16
|
+
elsif block
|
17
|
+
CattrProxy.new(self).send(name, value, &block)
|
18
|
+
end
|
15
19
|
else
|
16
|
-
CattrProxy.new(self)
|
20
|
+
CattrProxy.new(self).send('%s=' % name, nil)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|