u-attributes 0.4.0 → 0.5.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/Gemfile.lock +1 -1
- data/lib/micro/attributes/macros.rb +4 -4
- data/lib/micro/attributes/utils.rb +15 -0
- data/lib/micro/attributes/version.rb +1 -1
- data/lib/micro/attributes.rb +6 -9
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f28992fcd550ab8d700f8d722af72a486c84cdc5cb5d8fd526dd653d0f88ffb9
|
4
|
+
data.tar.gz: 9896e8b25b7abcb11503bd0f11f91ddcb4f0bcfcbbe6a5467928a791da7f8d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77934dec03187c8b45ff2c9e1577472dc7b2a7633cae3edec6c2a9d093acb35262f10e625ffb8ac086d949f41f8a0b1d46f1e57df585b03d0f9b51b72a2ff53
|
7
|
+
data.tar.gz: bd186e19af413b6bf26943fe4b527f285725b947226a65bc11ac35b5909883515e09267a11bbbe812e941d3aebb586c4535d406d0f7c2f6079fa42f1346ea82d
|
data/Gemfile.lock
CHANGED
@@ -41,10 +41,10 @@ module Micro
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def attributes_data(arg)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
__attributes_data.merge(
|
45
|
+
Utils.hash_argument!(arg)
|
46
|
+
.each_with_object({}) { |(key, val), memo| memo[key.to_s] = val }
|
47
|
+
)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Micro
|
4
|
+
module Attributes
|
5
|
+
module Utils
|
6
|
+
ARGUMENT_ERROR_MSG = 'argument must be a Hash'
|
7
|
+
|
8
|
+
def self.hash_argument!(arg)
|
9
|
+
return arg if arg.is_a?(Hash)
|
10
|
+
|
11
|
+
raise ArgumentError, ARGUMENT_ERROR_MSG
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/micro/attributes.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "micro/attributes/version"
|
4
|
+
require "micro/attributes/utils"
|
4
5
|
require "micro/attributes/macros"
|
5
6
|
|
6
7
|
module Micro
|
@@ -16,8 +17,8 @@ module Micro
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def base.inherited(subclass)
|
19
|
-
self.attributes_data({}) do |
|
20
|
-
|
20
|
+
self.attributes_data({}).each do |name, value|
|
21
|
+
subclass.attribute(value.nil? ? name : {name => value})
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -49,12 +50,8 @@ module Micro
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def attributes=(arg)
|
52
|
-
|
53
|
-
|
54
|
-
self.class.attributes_data(arg) do |data|
|
55
|
-
data.each do |name, value|
|
56
|
-
instance_variable_set("@#{name}", data[name]) if attribute?(name)
|
57
|
-
end
|
53
|
+
self.class.attributes_data(Utils.hash_argument!(arg)).each do |name, value|
|
54
|
+
instance_variable_set("@#{name}", value) if attribute?(name)
|
58
55
|
end
|
59
56
|
end
|
60
57
|
|
@@ -66,7 +63,7 @@ module Micro
|
|
66
63
|
end
|
67
64
|
end
|
68
65
|
|
69
|
-
self.class.attributes_data(state)
|
66
|
+
self.class.attributes_data(state)
|
70
67
|
end
|
71
68
|
|
72
69
|
protected :attributes=
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: u-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Serradura
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- bin/setup
|
59
59
|
- lib/micro/attributes.rb
|
60
60
|
- lib/micro/attributes/macros.rb
|
61
|
+
- lib/micro/attributes/utils.rb
|
61
62
|
- lib/micro/attributes/version.rb
|
62
63
|
- lib/u-attributes.rb
|
63
64
|
- micro-attributes.gemspec
|