u-attributes 0.1.0 → 0.2.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/lib/micro/attributes/macros.rb +1 -1
- data/lib/micro/attributes/version.rb +1 -1
- data/lib/micro/attributes.rb +14 -2
- 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: 6c1299b85819a1443c0bfbd3d64afcb4ab902e0ed7664df011f19cf9e4849d1d
|
4
|
+
data.tar.gz: 181160fdc96e1d4fe21ea5b84aedd0dac595cb2345db515096bb5ce02a932ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97c6d8ab9ada8548382aebea4f396c2b32d7769fa583ee4476cd974e02b6623ebbad5fb5fed18d6960875f52f36165146b00696a4f763b6c199a5b8c948e59b9
|
7
|
+
data.tar.gz: 3749512fc8eee2a6508d9901205a9655dfad0b503db81b18eb52c70fecbf0f24c16a2d82c3639daaa67f90816ee057457d99a950dc7ed7d5a070009df1030712
|
data/lib/micro/attributes.rb
CHANGED
@@ -7,11 +7,23 @@ module Micro
|
|
7
7
|
module Attributes
|
8
8
|
def self.included(base)
|
9
9
|
base.extend Macros
|
10
|
+
|
10
11
|
base.class_eval do
|
11
12
|
private_class_method :__attribute
|
12
13
|
private_class_method :__attributes
|
13
14
|
private_class_method :__attributes_defaults
|
14
15
|
end
|
16
|
+
|
17
|
+
def base.inherited(subclass)
|
18
|
+
self.attributes_data({}) do |data|
|
19
|
+
values = data.each_with_object(a: [], h: {}) do |(k, v), m|
|
20
|
+
v.nil? ? m[:a] << k : m[:h][k] = v
|
21
|
+
end
|
22
|
+
|
23
|
+
subclass.attributes(values[:a])
|
24
|
+
subclass.attributes(values[:h])
|
25
|
+
end
|
26
|
+
end
|
15
27
|
end
|
16
28
|
|
17
29
|
def self.to_initialize
|
@@ -33,7 +45,7 @@ module Micro
|
|
33
45
|
end
|
34
46
|
|
35
47
|
def attributes=(params)
|
36
|
-
self.class.
|
48
|
+
self.class.attributes_data(params) do |data|
|
37
49
|
data.each do |name, value|
|
38
50
|
instance_variable_set("@#{name}", data[name]) if attribute?(name)
|
39
51
|
end
|
@@ -48,7 +60,7 @@ module Micro
|
|
48
60
|
memo[name] = instance_variable_get(iv_name) if is_defined
|
49
61
|
end
|
50
62
|
|
51
|
-
self.class.
|
63
|
+
self.class.attributes_data(state) { |data| data }
|
52
64
|
end
|
53
65
|
|
54
66
|
protected :attributes=
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: u-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Serradura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|