class-mattr 0.2.0 → 0.3.0
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 +1 -1
- data/lib/lib/proxy.rb +9 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98aa4f37bab212f13051bd04734833fef9cf466cdf5b2bafb0f01834aac58ff6
|
4
|
+
data.tar.gz: 8dfb42379c98d86561d3ab895131222d9af02cc4e55d0ed45890c29e08ec0194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38a00df2e42a4e9098027a70869e0935411c0077f1014f093ca0699ce8507907b54a5b157af72ff4d60813aa7c112d712342582ccbfba48cab2f6af92e536fac
|
7
|
+
data.tar.gz: c7a962669169f719d140ee6e691b8684d5761290abf955a777e0642d262c62da89607dc6cdf02f0619e5641ab051161a69737e7cd531667bc61a8c0420bba60d
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/lib/base.rb
CHANGED
data/lib/lib/proxy.rb
CHANGED
@@ -14,22 +14,15 @@ module ClassMattr
|
|
14
14
|
MATTRS[klass] ||= {}
|
15
15
|
el = MATTRS[klass][name.to_sym] ||= {}
|
16
16
|
|
17
|
-
if
|
18
|
-
|
19
|
-
# convert to array and push
|
20
|
-
el[trait] = [el[trait]] unless el[trait].is_a?(Array)
|
21
|
-
el[trait].push opts
|
22
|
-
else
|
23
|
-
# default value if true if no argument provided
|
24
|
-
el[trait] = opts.nil? ? true : opts
|
25
|
-
end
|
17
|
+
# default value if true if no argument provided
|
18
|
+
el[trait] = opts.nil? ? true : opts
|
26
19
|
end
|
27
20
|
end
|
28
21
|
|
29
22
|
def _get name
|
30
23
|
for klass in @host.ancestors.map(&:to_s)
|
31
24
|
return {} if klass == 'ClassMattr'
|
32
|
-
|
25
|
+
|
33
26
|
hash = MATTRS.dig(klass, name.to_sym)
|
34
27
|
return hash if hash
|
35
28
|
end
|
@@ -37,6 +30,12 @@ module ClassMattr
|
|
37
30
|
raise 'ClassMattr not included?'
|
38
31
|
end
|
39
32
|
|
33
|
+
def get_hash
|
34
|
+
name = :__mattr_tmp
|
35
|
+
_set name
|
36
|
+
MATTRS[@host.to_s].delete(name)
|
37
|
+
end
|
38
|
+
|
40
39
|
def method_missing name, value=nil
|
41
40
|
@@mattrs.push [@host.to_s, name.to_s, value]
|
42
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class-mattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-02
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Mothod attributes are not natively supported by ruby, this fixes the
|
14
14
|
problem!
|