quick_class 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/quick_class.rb +1 -3
- data/lib/version.rb +1 -1
- 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: 9b7f9fa6755b194bd8b04a6fbcadc52e2c1b760d3e3472ab35b6d085e9f59962
|
4
|
+
data.tar.gz: d43a140c80cca2b630bc58d4a2a580ec86452e5b80366074cc86348a4e3775e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 327f9f30def3722ae3b1c88ecdbcf7b5998dd575aa64d868eeae056f1bcc9481aabe56831681bf16f7e3af5cb102a8ea5b9f1d014e8544c1c008c665a0bab301
|
7
|
+
data.tar.gz: b7918f5f13ce0920cdc5148d21dfb131ac3d7ff04a1f32e7a10f6d787ebb17b95196ae63647c74bd12099d9462be61200f9352db583d9a9bb2f0322e22a0811c
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ The `default` method is also defined, which is the same as passing `attributes`
|
|
38
38
|
|
39
39
|
```
|
40
40
|
Foo.default
|
41
|
-
# => #<Foo:0x007fef7398f6b0 @a=0, @b=
|
41
|
+
# => #<Foo:0x007fef7398f6b0 @a=0, @b=1>
|
42
42
|
```
|
43
43
|
|
44
44
|
It works with interitance also:
|
@@ -73,6 +73,6 @@ Foo.default.b
|
|
73
73
|
# => 1
|
74
74
|
```
|
75
75
|
|
76
|
-
The whole source code is
|
76
|
+
The whole source code is 12 un-minified lines without comments.
|
77
77
|
|
78
78
|
use at own risk
|
data/lib/quick_class.rb
CHANGED
@@ -3,9 +3,7 @@ class QuickClass
|
|
3
3
|
# main public method - define attributes for a class
|
4
4
|
def self.attributes=(**keyvals)
|
5
5
|
# if attributes is already defined, delete the attr_accessor methods
|
6
|
-
@attributes&.each_key
|
7
|
-
[:"#{k}", :"#{k}="].each { |m| send :undef_method, m }
|
8
|
-
end
|
6
|
+
@attributes&.each_key { |k| [:"#{k}", :"#{k}="].each &method(:undef_method) }
|
9
7
|
# define attributes at the keyvals passed to this method as an argument,
|
10
8
|
# merged with the attributes of the superclass, if there is one.
|
11
9
|
@attributes = keyvals.merge(superclass&.attributes || {})
|
data/lib/version.rb
CHANGED