class-cattr 0.1.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/lib/lib/base.rb +4 -0
- data/lib/lib/proxy.rb +7 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e36c2669386c70f837891e37cd035574309c08127c0d8982cdc94b4f0b7a400
|
|
4
|
+
data.tar.gz: 6edda84721643fa97c763f4a41364134ba85be03d37885a977c3104a1cecbca2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f0b0d0a2b8f31d1a82476adb734f7c704a926cd314f0b7dfd54da7528f386c7a193518f7a5beb9b4b1319be6dd054b4e7e90668f852a409caf44b368d384c210
|
|
7
|
+
data.tar.gz: b8eb643415ad4a8d9872537910f917955b28ffc120c7719680895c122206e4dc17a89f36724dab674b3b679e704c1f37cdb89288be5b0865256338f129f8f085
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1
|
|
1
|
+
0.2.1
|
data/lib/lib/base.rb
CHANGED
|
@@ -3,6 +3,10 @@ class Class
|
|
|
3
3
|
return CattrProxy.new(self) unless name
|
|
4
4
|
|
|
5
5
|
if value != :_nil || block
|
|
6
|
+
define_singleton_method('%s=' % name) do |arg|
|
|
7
|
+
CattrProxy.new(self).send('%s=' % name, arg)
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
define_singleton_method(name) do |arg = :_nil|
|
|
7
11
|
if arg == :_nil
|
|
8
12
|
CattrProxy.new(self).send(name)
|
data/lib/lib/proxy.rb
CHANGED
|
@@ -18,9 +18,13 @@ class CattrProxy
|
|
|
18
18
|
|
|
19
19
|
for el in @host.ancestors
|
|
20
20
|
if el.respond_to?(:superclass) && el != Object && el.instance_variable_defined?(name)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
local = el.instance_variable_get name
|
|
22
|
+
|
|
23
|
+
if local === Proc
|
|
24
|
+
local = @host.instance_exec &local
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
return local
|
|
24
28
|
end
|
|
25
29
|
end
|
|
26
30
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: class-cattr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dino Reic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Class attributes are not natively supported by ruby, this fixes the problem!
|
|
14
14
|
email: reic.dino@gmail.com
|
|
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
requirements: []
|
|
42
|
-
rubygems_version: 3.
|
|
42
|
+
rubygems_version: 3.2.22
|
|
43
43
|
signing_key:
|
|
44
44
|
specification_version: 4
|
|
45
45
|
summary: Ruby class attributes
|