lib/neo4j/active_rel/property.rb in neo4j-5.0.15 vs lib/neo4j/active_rel/property.rb in neo4j-5.1.0.rc.1
- old
+ new
@@ -17,19 +17,20 @@
# @return [String] a string representing the relationship type that will be created
def type
self.class._type
end
- def initialize(attributes = {}, options = {})
- super(attributes, options)
+ def initialize(attributes = nil)
+ super(attributes)
send_props(@relationship_props) unless @relationship_props.nil?
end
module ClassMethods
# Extracts keys from attributes hash which are relationships of the model
# TODO: Validate separately that relationships are getting the right values? Perhaps also store the values and persist relationships on save?
def extract_association_attributes!(attributes)
+ return if attributes.blank?
{}.tap do |relationship_props|
attributes.each_key do |key|
relationship_props[key] = attributes.delete(key) if [:from_node, :to_node].include?(key)
end
end
@@ -53,15 +54,26 @@
def load_entity(id)
Neo4j::Node.load(id)
end
+ def creates_unique
+ @creates_unique = true
+ end
+
def creates_unique_rel
- @unique = true
+ warning = <<-WARNING
+creates_unique_rel() is deprecated and will be removed from future releases,
+use creates_unique() instead.
+WARNING
+
+ ActiveSupport::Deprecation.warn(warning, caller)
+
+ creates_unique
end
- def unique?
- !!@unique
+ def creates_unique?
+ !!@creates_unique
end
end
private