config_mapper 1.3.1 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config_mapper/config_struct.rb +12 -5
- data/lib/config_mapper/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7de0e012b37758b972449905dd89e25fff9c5f78
|
4
|
+
data.tar.gz: ea363b40759c5fa82e7531c088486eb535dc30f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4fa80171dd00dfec8c0dfc7a6f561bfe400045e01713bf928136d21ab6fe3df3fe06c212620ab16c6d8b9b5e452e3217b5fa7be52fe90fbec8031724e0f1009
|
7
|
+
data.tar.gz: 2fcacd97d600bb870f84ef1c8c7c9b3c991ef383db9ee6965bffb63be81d6c15de6ca461e8b8acc90fb4fababcdd9d40a67bac2647bd4127c60bc4e97b8cc282
|
@@ -102,10 +102,17 @@ module ConfigMapper
|
|
102
102
|
@declared_component_dicts ||= []
|
103
103
|
end
|
104
104
|
|
105
|
+
def for_all(attribute, &action)
|
106
|
+
ancestors.each do |klass|
|
107
|
+
next unless klass.respond_to?(attribute)
|
108
|
+
klass.public_send(attribute).each(&action)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
105
112
|
end
|
106
113
|
|
107
114
|
def initialize
|
108
|
-
self.class.attribute_initializers
|
115
|
+
self.class.for_all(:attribute_initializers) do |name, initializer|
|
109
116
|
instance_variable_set("@#{name}", initializer.call)
|
110
117
|
end
|
111
118
|
end
|
@@ -134,7 +141,7 @@ module ConfigMapper
|
|
134
141
|
#
|
135
142
|
def to_h
|
136
143
|
{}.tap do |result|
|
137
|
-
self.class.attribute_initializers
|
144
|
+
self.class.for_all(:attribute_initializers) do |attr_name, _|
|
138
145
|
value = send(attr_name)
|
139
146
|
if value && value.respond_to?(:to_h) && !value.is_a?(Array)
|
140
147
|
value = value.to_h
|
@@ -148,10 +155,10 @@ module ConfigMapper
|
|
148
155
|
|
149
156
|
def components
|
150
157
|
{}.tap do |result|
|
151
|
-
self.class.declared_components
|
158
|
+
self.class.for_all(:declared_components) do |name|
|
152
159
|
result[".#{name}"] = instance_variable_get("@#{name}")
|
153
160
|
end
|
154
|
-
self.class.declared_component_dicts
|
161
|
+
self.class.for_all(:declared_component_dicts) do |name|
|
155
162
|
instance_variable_get("@#{name}").each do |key, value|
|
156
163
|
result[".#{name}[#{key.inspect}]"] = value
|
157
164
|
end
|
@@ -169,7 +176,7 @@ module ConfigMapper
|
|
169
176
|
|
170
177
|
def missing_required_attribute_errors
|
171
178
|
{}.tap do |errors|
|
172
|
-
self.class.required_attributes
|
179
|
+
self.class.for_all(:required_attributes) do |name|
|
173
180
|
if instance_variable_get("@#{name}").nil?
|
174
181
|
errors[".#{name}"] = NoValueProvided.new
|
175
182
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.6.12
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Maps config data onto plain old objects
|