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 +4 -4
- data/lib/glue_gun/dsl.rb +18 -16
- data/lib/glue_gun/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b7b46d98a9c33d613f4a0c6aa3cd0b7b43f73f2117eadbed6a3ed3146536880
|
4
|
+
data.tar.gz: 7ec3d164ae20f7ecd12aa85d826bffc0adeed0de2faf1b0e8e52c403bb8a032e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
-
|
194
|
+
value = attr_config.process_value(value, self) if attr_config.respond_to?(:process_value)
|
196
195
|
|
197
|
-
|
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
|
-
|
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
|
data/lib/glue_gun/version.rb
CHANGED