glue_gun_dsl 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/glue_gun/dsl.rb +18 -2
- data/lib/glue_gun/version.rb +1 -1
- 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: cc6aaef2a48bc81e0383a4b88f0afc691a3f99097e12877579c7d579953cfea7
|
4
|
+
data.tar.gz: ceb228b7381a0fbc7e2b3c07fe650cc05d89524dcec7199490fafb8813117bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7624649374c85a5822bb6a74096e50c69947db98bd1097ec020e3e82edde37c35a9057905534271da63385ef1c37d43b479712d0442247837151c0ab23ef9cbc
|
7
|
+
data.tar.gz: 1f18555d5938dc3fb16bed600e3216502601e0b97c8a7c0998b22dd636cea40263f5ec7225767232e873778690c5ca0d752786c4e5017b371c35b17d191277aa
|
data/lib/glue_gun/dsl.rb
CHANGED
@@ -107,13 +107,14 @@ module GlueGun
|
|
107
107
|
options = {}
|
108
108
|
end
|
109
109
|
is_array = options[:array] || false
|
110
|
+
is_hash = options[:hash] || false
|
110
111
|
|
111
112
|
if factory_class.present?
|
112
|
-
dependency_definitions[component_type] = { factory_class: factory_class, array: is_array }
|
113
|
+
dependency_definitions[component_type] = { factory_class: factory_class, array: is_array, hash: is_hash }
|
113
114
|
else
|
114
115
|
dependency_builder = DependencyBuilder.new(component_type)
|
115
116
|
dependency_builder.instance_eval(&block)
|
116
|
-
dependency_definitions[component_type] = { builder: dependency_builder, array: is_array }
|
117
|
+
dependency_definitions[component_type] = { builder: dependency_builder, array: is_array, hash: is_hash }
|
117
118
|
end
|
118
119
|
|
119
120
|
# Define singleton method to allow hardcoding dependencies in subclasses
|
@@ -180,6 +181,7 @@ module GlueGun
|
|
180
181
|
def initialize_dependency(component_type, init_args = {}, definition = nil)
|
181
182
|
definition ||= self.class.dependency_definitions[component_type]
|
182
183
|
is_array = definition[:array]
|
184
|
+
is_hash = definition[:hash]
|
183
185
|
|
184
186
|
if is_array
|
185
187
|
dep = []
|
@@ -189,6 +191,14 @@ module GlueGun
|
|
189
191
|
dep.push(d)
|
190
192
|
config.push(c)
|
191
193
|
end
|
194
|
+
elsif is_hash
|
195
|
+
dep = {}
|
196
|
+
config = {}
|
197
|
+
init_args.each do |key, args|
|
198
|
+
d, c = initialize_single_dependency(component_type, args, definition)
|
199
|
+
dep[key] = d
|
200
|
+
config[key] = c
|
201
|
+
end
|
192
202
|
else
|
193
203
|
dep, config = initialize_single_dependency(component_type, init_args, definition)
|
194
204
|
end
|
@@ -341,6 +351,12 @@ module GlueGun
|
|
341
351
|
dependency_instance.zip(option_config).each do |dep, opt|
|
342
352
|
propagate_attribute_to_instance(attr_name, value, dep, opt)
|
343
353
|
end
|
354
|
+
elsif dependency_instance.is_a?(Hash)
|
355
|
+
option_config = dependencies.dig(component_type, :option)
|
356
|
+
|
357
|
+
dependency_instance.each do |key, dep|
|
358
|
+
propagate_attribute_to_instance(attr_name, value, dep, option_config[key])
|
359
|
+
end
|
344
360
|
else
|
345
361
|
option_config = dependencies.dig(component_type, :option)
|
346
362
|
next unless option_config
|
data/lib/glue_gun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glue_gun_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Shollenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|