glue_gun_dsl 0.1.15 → 0.1.16

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: a573097a1db8e4af5573a1b0374e43dc12dcadc22f4e4a950bd6d5fe4a9084a1
4
- data.tar.gz: 1db836fbee10ab0594495e5f137f0337ec62a8b90eeabc29bc55be0dab6ade9b
3
+ metadata.gz: cc6aaef2a48bc81e0383a4b88f0afc691a3f99097e12877579c7d579953cfea7
4
+ data.tar.gz: ceb228b7381a0fbc7e2b3c07fe650cc05d89524dcec7199490fafb8813117bcc
5
5
  SHA512:
6
- metadata.gz: ad634073ed8206277b1eb502b2da7eff90e92cc820adcabc1dc647dee8e2f0c7cdf4ea7c2cc9fdd4b8a3b5f46caff7a6d4c55f82d3780a180b719af5729d4a51
7
- data.tar.gz: 3048844dcbae257696ab142798ead0957b97bda029c151da4d9e5181b90d3da43099ecd6ec79784efb2499b0fd699a0dca2e24513e1fc20c461dae3648a4390d
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GlueGun
4
- VERSION = "0.1.15"
4
+ VERSION = "0.1.16"
5
5
  end
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.15
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-15 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel