activecypher 0.10.0 → 0.10.1
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 +11 -6
- 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: 1f1c222ac52b28439402e7b5bdbd0b3245c2530ce75227a9b35ef47917225327
|
4
|
+
data.tar.gz: d0cb17f1db87febfdb693f0fc85970b1d4b8e6c7555ae5424be1b04cbcf1eee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a8f60aacaea3ed7b3a4fb53e92b042237392d809304f1d17c59ebdb3c6b8e4ea221c44beaa6868a7e2e80859bbdb6f438c1cff65b2eff186b4dcd2f18c9c43a
|
7
|
+
data.tar.gz: ea5cdba9b038ca87809698de82982613f3a1c6efc33365bf9b01f07216edbb5bfcf5007f07cd5b9f0d360a830ec86c95e9e00b695bdafc42ac1cc242ed7c663e
|
@@ -155,14 +155,14 @@ module ActiveCypher
|
|
155
155
|
|
156
156
|
# -- factories -----------------------------------------------
|
157
157
|
# Mirrors ActiveRecord.create
|
158
|
-
def create(attrs = {}, from_node:, to_node
|
159
|
-
new(attrs, from_node: from_node, to_node: to_node).tap(&:save)
|
158
|
+
def create(attrs = {}, from_node:, to_node:, **attribute_kwargs)
|
159
|
+
new(attrs, from_node: from_node, to_node: to_node, **attribute_kwargs).tap(&:save)
|
160
160
|
end
|
161
161
|
|
162
162
|
# Bang version of create - raises exception if save fails
|
163
163
|
# For when you want your relationship failures to be as dramatic as your breakups
|
164
|
-
def create!(attrs = {}, from_node:, to_node
|
165
|
-
relationship = create(attrs, from_node: from_node, to_node: to_node)
|
164
|
+
def create!(attrs = {}, from_node:, to_node:, **attribute_kwargs)
|
165
|
+
relationship = create(attrs, from_node: from_node, to_node: to_node, **attribute_kwargs)
|
166
166
|
if relationship.persisted?
|
167
167
|
relationship
|
168
168
|
else
|
@@ -267,10 +267,15 @@ module ActiveCypher
|
|
267
267
|
attr_accessor :from_node, :to_node
|
268
268
|
attr_reader :new_record
|
269
269
|
|
270
|
-
def initialize(attrs = {}, from_node: nil, to_node: nil)
|
270
|
+
def initialize(attrs = {}, from_node: nil, to_node: nil, **attribute_kwargs)
|
271
271
|
_run(:initialize) do
|
272
272
|
super()
|
273
|
-
|
273
|
+
|
274
|
+
# Merge explicit attrs hash with keyword arguments for attributes.
|
275
|
+
# Note: `attribute_kwargs` takes precedence over `attrs` for keys that exist in both.
|
276
|
+
combined_attrs = attrs.merge(attribute_kwargs)
|
277
|
+
assign_attributes(combined_attrs) if combined_attrs.any?
|
278
|
+
|
274
279
|
@from_node = from_node
|
275
280
|
@to_node = to_node
|
276
281
|
@new_record = true
|