glue_gun_dsl 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd26c5b4ba6c9831e91835a2d771d9cec019b94d25124e68ed006ba40aa545e8
4
- data.tar.gz: 7d5572e0ff530ef4ed03b2ae8b8cde2261b7215fed9cec34f81722a0238287b6
3
+ metadata.gz: 7b7b46d98a9c33d613f4a0c6aa3cd0b7b43f73f2117eadbed6a3ed3146536880
4
+ data.tar.gz: 7ec3d164ae20f7ecd12aa85d826bffc0adeed0de2faf1b0e8e52c403bb8a032e
5
5
  SHA512:
6
- metadata.gz: 5847c254dfe071b87b731d835a50b62be82f9c7638b281174e3aacd60cc29621c8c7027abcb09597e426b2275b7183b2ba8b6dd6f1fc192e0d50f7c4bc65b954
7
- data.tar.gz: ebcea322a43228b6912176dfd7bb3a66df37da5ea5ce82c1415d1fe93ab1961b1ce7a244da3590a627488d0d6c62a24f9fe3a70d055679d347077276b127d011
6
+ metadata.gz: 4ea5e725ad6f9367807b69f7f82a5c5fef8ad3578f1394f9bf9407135e599e7ffa797efa80d76842ce7fc4ff5c114b81d090c831d3d90966d34e087c390deb99
7
+ data.tar.gz: 219174af57c3c3fc4a1b9ab242ead40375c11fe9ee58a3dc084db6bc6615b6d2c908237f1b21eec55059382eac6421f4a649549a657194b6ef3e1293a14298a7
data/lib/glue_gun/dsl.rb CHANGED
@@ -81,7 +81,7 @@ module GlueGun
81
81
 
82
82
  attribute_methods_module.class_eval do
83
83
  define_method "#{name}=" do |value|
84
- super(value)
84
+ value = super(value)
85
85
  propagate_attribute_change(name, value) if initialized?
86
86
  end
87
87
  end
@@ -181,21 +181,19 @@ module GlueGun
181
181
  def build_dependency_attributes(option_config, dep_attributes)
182
182
  option_config.attributes.each do |attr_name, attr_config|
183
183
  # If the attribute is already provided, use it
184
- if dep_attributes.key?(attr_name)
185
- value = dep_attributes[attr_name]
186
- else
187
- value = if attr_config.source && respond_to?(attr_config.source)
188
- send(attr_config.source)
189
- elsif respond_to?(attr_name)
190
- send(attr_name)
191
- else
192
- attr_config.default
193
- end
184
+ value = if dep_attributes.key?(attr_name)
185
+ dep_attributes[attr_name]
186
+ elsif attr_config.source && respond_to?(attr_config.source)
187
+ send(attr_config.source)
188
+ elsif respond_to?(attr_name)
189
+ send(attr_name)
190
+ else
191
+ attr_config.default
192
+ end
194
193
 
195
- value = attr_config.process_value(value, self) if attr_config.respond_to?(:process_value)
194
+ value = attr_config.process_value(value, self) if attr_config.respond_to?(:process_value)
196
195
 
197
- dep_attributes[attr_name] = value
198
- end
196
+ dep_attributes[attr_name] = value
199
197
 
200
198
  # After getting the value, check if it's required and nil
201
199
  if value.nil? && attr_config.required
@@ -268,8 +266,12 @@ module GlueGun
268
266
  (attr_config.source == attr_name.to_sym) || (attr_config.name == attr_name.to_sym)
269
267
  end
270
268
 
271
- bound_attrs.each do |dep_attr_name, _|
272
- dependency_instance.send("#{dep_attr_name}=", value) if dependency_instance.respond_to?("#{dep_attr_name}=")
269
+ bound_attrs.each do |dep_attr_name, config_attr|
270
+ block = config_attr.block.present? ? config_attr.block : proc { |att| att }
271
+ if dependency_instance.respond_to?("#{dep_attr_name}=")
272
+ dependency_instance.send("#{dep_attr_name}=",
273
+ block.call(value))
274
+ end
273
275
  end
274
276
  end
275
277
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GlueGun
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glue_gun_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Shollenberger