activecypher 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_cypher/relationship.rb +18 -1
- data/lib/active_cypher/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: 3040943b0361f537dd3f6a68320463195607e72001f6e25b340d81212cd7a13a
|
4
|
+
data.tar.gz: 6d35f5d0e9c21d9e695ab898896f047fa36ab2aa8d08f997b8ad67e4a5ae0cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dddf85e77779795ecc95dd81834c0b4c13213ece522e019f50345f4ca1bd0944241e58ce0d4dfcbaa97f3e9b951cc44dc311d41b17bdf25578ca8f43e9bc5155
|
7
|
+
data.tar.gz: 74d562c623379a836dc1166a7fa3caf7d94743b728bba1f1f84acc3377d59f2278147cbb874c013981c0652cd360f49a11f7fc738f28cc635e2ecb9cbfc8d360
|
@@ -39,6 +39,7 @@ module ActiveCypher
|
|
39
39
|
include ActiveModel::Attributes
|
40
40
|
include ActiveModel::Dirty
|
41
41
|
include ActiveModel::Naming
|
42
|
+
include ActiveModel::Validations
|
42
43
|
|
43
44
|
include Model::ConnectionOwner
|
44
45
|
include Logging
|
@@ -290,7 +291,9 @@ module ActiveCypher
|
|
290
291
|
# --------------------------------------------------------------
|
291
292
|
# Persistence API
|
292
293
|
# --------------------------------------------------------------
|
293
|
-
def save
|
294
|
+
def save(validate: true)
|
295
|
+
return false if validate && !valid?
|
296
|
+
|
294
297
|
_run(:save) do
|
295
298
|
if new_record?
|
296
299
|
_run(:create) { create_relationship }
|
@@ -303,6 +306,20 @@ module ActiveCypher
|
|
303
306
|
false
|
304
307
|
end
|
305
308
|
|
309
|
+
# Bang version of save - raises exception if save fails
|
310
|
+
# For when you want your relationship persistence to be as dramatic as your code reviews
|
311
|
+
def save!
|
312
|
+
if save
|
313
|
+
self
|
314
|
+
else
|
315
|
+
error_msgs = errors.full_messages.join(', ')
|
316
|
+
error_msgs = 'Validation failed' if error_msgs.empty?
|
317
|
+
raise ActiveCypher::RecordNotSaved,
|
318
|
+
"#{self.class} could not be saved: #{error_msgs}. " \
|
319
|
+
'Perhaps this relationship was never meant to be?'
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
306
323
|
def destroy
|
307
324
|
_run(:destroy) do
|
308
325
|
raise 'Cannot destroy a new relationship' if new_record?
|