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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 697e6798ae2b2c4c3db3f4e3cd9b2c65ccc8081386636c08366e4d023cb04afe
4
- data.tar.gz: f7a025244f1b5627691676d784658d2a14a289914533e17f4c1daca896c6ebdf
3
+ metadata.gz: b5b050524f016e18d7b9937fbc5bbba5e8bf989690fdfda10a6bd0adf09aeb86
4
+ data.tar.gz: 2eab6853e671117b5253de7a88b9edb0f5274c5688ddd5817ce35ad77d8185de
5
5
  SHA512:
6
- metadata.gz: 8d32f478f2e294ae9510abb04b0ac5b5490c8468918879363f790eebc5167d7c3e28ec5edf9675301a2a211b7f5493bcf24c1884295598e9cf859f5b6b146f21
7
- data.tar.gz: ee627464ed957cffac221bd2d701e9a9deba768e1cac558349878d101b67281a2c5977379f79496af43ed7bdbc392489c60e7d3fec2d09445b2e35526d2d256f
6
+ metadata.gz: 30b842fe667aa8f8785a903d1b61f3e3fb65799cc417214392ecde7022251fd3ab212f81d5d26ea9d8818ca3241649729eb92b8e6454c128a8659f12d3f2f96a
7
+ data.tar.gz: c000b550317b50a2c17c985f8d7e574e4bef04444e20f9cfdecef46420efa14e931a11f01334e1ad06f04889a60a3dedd29cdd3118fab478236b0703a06b3bbb
@@ -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.respond_to?(:serialize) ? dep_instance.serialize : dep_instance.attributes.deep_compact
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.respond_to?(:serialize) ? service_object.serialize : service_object.attributes.deep_compact
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GlueGun
4
- VERSION = "0.1.27"
4
+ VERSION = "0.1.28"
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.27
4
+ version: 0.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Shollenberger