class-cattr 0.1.4 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/lib/lib/base.rb +4 -0
  4. data/lib/lib/proxy.rb +7 -3
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83e87f619d4c8061b483373abf95a7b15f326da2d106e5967fea92ffc93198e3
4
- data.tar.gz: 7c9d0d74d86608899545077cbbea4458320cb0c3db9169298f46cbfd90e81034
3
+ metadata.gz: 7e36c2669386c70f837891e37cd035574309c08127c0d8982cdc94b4f0b7a400
4
+ data.tar.gz: 6edda84721643fa97c763f4a41364134ba85be03d37885a977c3104a1cecbca2
5
5
  SHA512:
6
- metadata.gz: 387c3bf605c2e451665297427a694958a0c3fa3c6b7d29ba87fef87130dd33cf6c1eb446586703195a339a9fcdc17e62040ce94e422879f30e0a74d3facbf836
7
- data.tar.gz: eba2ad18def2ecc2378929fbfb364e1071903eb270e040b5aca043fffa238096c5515e7d7b31ae356a1eb4aa4bfd1f4097bc98e0cd319a9be038a38000aa70d9
6
+ metadata.gz: f0b0d0a2b8f31d1a82476adb734f7c704a926cd314f0b7dfd54da7528f386c7a193518f7a5beb9b4b1319be6dd054b4e7e90668f852a409caf44b368d384c210
7
+ data.tar.gz: b8eb643415ad4a8d9872537910f917955b28ffc120c7719680895c122206e4dc17a89f36724dab674b3b679e704c1f37cdb89288be5b0865256338f129f8f085
data/.version CHANGED
@@ -1 +1 @@
1
- 0.1.4
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
- value = el.instance_variable_get name
22
- value = value.call if value === Proc
23
- return value
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
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: 2021-05-22 00:00:00.000000000 Z
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.0.6
42
+ rubygems_version: 3.2.22
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Ruby class attributes