glue_gun_dsl 0.1.27 → 0.1.29
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 +24 -6
- data/lib/glue_gun/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c7ef75df045c142a9b1175b91ad7f7745179ea3dacfa5c30c2b2409e1d4fe78
|
4
|
+
data.tar.gz: 3e55b0b662c7ccf655e784cc9672a5e6f7a792268bd0140d28e66b8b4439b627
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f97de5312eaaae95f2c57bd8691a4751f55902ffdd7f8140d0f11a6548c2004afc47f31612f1e7ad14b42e2d530bdbf588349a9e8c4c0645a8dc760da3b383c4
|
7
|
+
data.tar.gz: 11916bd9c893ce87058a1fbf1e4f2b4b9fbcd16b8867493e35c932622e8ebcbe43ed8cee3291219aa24a274cb60a79f6d1f9ae15c67c712e1bf3f3398805f6a6
|
data/lib/glue_gun/model.rb
CHANGED
@@ -139,6 +139,10 @@ module GlueGun
|
|
139
139
|
|
140
140
|
private
|
141
141
|
|
142
|
+
def awesome_print(message)
|
143
|
+
ap message
|
144
|
+
end
|
145
|
+
|
142
146
|
def build_service_object(attributes)
|
143
147
|
self.class.send(:attr_reader, service_attribute_name)
|
144
148
|
service_class = resolve_service_class(attributes)
|
@@ -148,9 +152,9 @@ module GlueGun
|
|
148
152
|
begin
|
149
153
|
service_instance = service_class.new(service_attributes)
|
150
154
|
rescue StandardError => e
|
151
|
-
|
152
|
-
|
153
|
-
|
155
|
+
awesome_print %(Error building service object #{service_class}:)
|
156
|
+
awesome_print e.message
|
157
|
+
awesome_print e.backtrace
|
154
158
|
raise e
|
155
159
|
end
|
156
160
|
instance_variable_set("@#{service_attribute_name}", service_instance)
|
@@ -159,8 +163,10 @@ module GlueGun
|
|
159
163
|
def resolve_service_type(attributes, initializing = false)
|
160
164
|
attrs = if initializing || !persisted? || attributes.key?(self.class.option_key)
|
161
165
|
attributes
|
162
|
-
|
166
|
+
elsif respond_to?(self.class.option_key)
|
163
167
|
{ self.class.option_key => send(self.class.option_key) }
|
168
|
+
else
|
169
|
+
{ self.class.option_key => self.class.service_registry.default_key }
|
164
170
|
end
|
165
171
|
attrs[self.class.option_key] || self.class.service_registry.default_key
|
166
172
|
end
|
@@ -211,6 +217,18 @@ module GlueGun
|
|
211
217
|
end.symbolize_keys
|
212
218
|
end
|
213
219
|
|
220
|
+
def serialize_object(object)
|
221
|
+
if object.respond_to?(:serialize)
|
222
|
+
object.serialize
|
223
|
+
elsif object.respond_to?(:attributes)
|
224
|
+
object.attributes.deep_compact
|
225
|
+
else
|
226
|
+
Hash[object.instance_variables.map do |var|
|
227
|
+
[var.to_s.delete("@"), object.instance_variable_get(var)]
|
228
|
+
end].deep_compact
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
214
232
|
def serialize_dependency(dependency, dep_instance = nil)
|
215
233
|
dep_instance = service_object.send(dependency) if dep_instance.nil?
|
216
234
|
return nil unless dep_instance.present?
|
@@ -225,7 +243,7 @@ module GlueGun
|
|
225
243
|
raise "Don't know how to serialize dependency of type #{dependency}, available options are #{opts.keys}. You didn't specify an option."
|
226
244
|
end
|
227
245
|
|
228
|
-
serialized = dep_instance
|
246
|
+
serialized = serialize_object(dep_instance)
|
229
247
|
{
|
230
248
|
selected_option => serialized
|
231
249
|
}
|
@@ -240,7 +258,7 @@ module GlueGun
|
|
240
258
|
end
|
241
259
|
|
242
260
|
def serialize_service_object
|
243
|
-
attrs = service_object
|
261
|
+
attrs = serialize_object(service_object)
|
244
262
|
deps = allowed_names(service_object.dependency_definitions.keys).inject({}) do |hash, dep|
|
245
263
|
hash.tap do
|
246
264
|
serialized = serialize_dependency(dep)
|
data/lib/glue_gun/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.29
|
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-
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|