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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da62e5027a9c9ecfb6d7df067a19e00b91d36685919f66bda2df807e733d3746
4
- data.tar.gz: '068d99c58374cb7c3e13cd709858e08249cc91ae87419256890a273ff6ef4115'
3
+ metadata.gz: 6c1299b85819a1443c0bfbd3d64afcb4ab902e0ed7664df011f19cf9e4849d1d
4
+ data.tar.gz: 181160fdc96e1d4fe21ea5b84aedd0dac595cb2345db515096bb5ce02a932ce6
5
5
  SHA512:
6
- metadata.gz: ad8f979116e3679ac2cdaf17bc8ad930dcbce0a7ae0e7cb5f6f1b798f2e727f8929072b3b2524671a303f9e928eccddab75a9d842efa88c132af3645624b8d5e
7
- data.tar.gz: a65f2eb363f14090d3f31e00e63ffbd1b1ff116ddc2f8bdf564309a0b1a7dc0d765bec639861c88ec00586d2dedb5f7289dda30cc52987d3e00483ef8090fdd5
6
+ metadata.gz: 97c6d8ab9ada8548382aebea4f396c2b32d7769fa583ee4476cd974e02b6623ebbad5fb5fed18d6960875f52f36165146b00696a4f763b6c199a5b8c948e59b9
7
+ data.tar.gz: 3749512fc8eee2a6508d9901205a9655dfad0b503db81b18eb52c70fecbf0f24c16a2d82c3639daaa67f90816ee057457d99a950dc7ed7d5a070009df1030712
@@ -39,7 +39,7 @@ module Micro
39
39
  args.flatten.each { |arg| attribute(arg) }
40
40
  end
41
41
 
42
- def attributes_to_set(arg)
42
+ def attributes_data(arg)
43
43
  normalized_params = arg.keys.each_with_object({}) do |key, memo|
44
44
  memo[key.to_s] = arg[key]
45
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  module Attributes
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -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.attributes_to_set(params) do |data|
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.attributes_to_set(state) { |data| data }
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.1.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-02 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler