glue_gun_dsl 0.1.27 → 0.1.28
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/model.rb +14 -2
- 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: b5b050524f016e18d7b9937fbc5bbba5e8bf989690fdfda10a6bd0adf09aeb86
|
4
|
+
data.tar.gz: 2eab6853e671117b5253de7a88b9edb0f5274c5688ddd5817ce35ad77d8185de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30b842fe667aa8f8785a903d1b61f3e3fb65799cc417214392ecde7022251fd3ab212f81d5d26ea9d8818ca3241649729eb92b8e6454c128a8659f12d3f2f96a
|
7
|
+
data.tar.gz: c000b550317b50a2c17c985f8d7e574e4bef04444e20f9cfdecef46420efa14e931a11f01334e1ad06f04889a60a3dedd29cdd3118fab478236b0703a06b3bbb
|
data/lib/glue_gun/model.rb
CHANGED
@@ -211,6 +211,18 @@ module GlueGun
|
|
211
211
|
end.symbolize_keys
|
212
212
|
end
|
213
213
|
|
214
|
+
def serialize_object(object)
|
215
|
+
if object.respond_to?(:serialize)
|
216
|
+
object.serialize
|
217
|
+
elsif object.respond_to?(:attributes)
|
218
|
+
object.attributes.deep_compact
|
219
|
+
else
|
220
|
+
Hash[object.instance_variables.map do |var|
|
221
|
+
[var.to_s.delete("@"), object.instance_variable_get(var)]
|
222
|
+
end].deep_compact
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
214
226
|
def serialize_dependency(dependency, dep_instance = nil)
|
215
227
|
dep_instance = service_object.send(dependency) if dep_instance.nil?
|
216
228
|
return nil unless dep_instance.present?
|
@@ -225,7 +237,7 @@ module GlueGun
|
|
225
237
|
raise "Don't know how to serialize dependency of type #{dependency}, available options are #{opts.keys}. You didn't specify an option."
|
226
238
|
end
|
227
239
|
|
228
|
-
serialized = dep_instance
|
240
|
+
serialized = serialize_object(dep_instance)
|
229
241
|
{
|
230
242
|
selected_option => serialized
|
231
243
|
}
|
@@ -240,7 +252,7 @@ module GlueGun
|
|
240
252
|
end
|
241
253
|
|
242
254
|
def serialize_service_object
|
243
|
-
attrs = service_object
|
255
|
+
attrs = serialize_object(service_object)
|
244
256
|
deps = allowed_names(service_object.dependency_definitions.keys).inject({}) do |hash, dep|
|
245
257
|
hash.tap do
|
246
258
|
serialized = serialize_dependency(dep)
|
data/lib/glue_gun/version.rb
CHANGED