lib/neo4j/active_rel/property.rb in neo4j-4.0.0 vs lib/neo4j/active_rel/property.rb in neo4j-4.1.0
- old
+ new
@@ -1,14 +1,14 @@
module Neo4j::ActiveRel
module Property
extend ActiveSupport::Concern
include Neo4j::Shared::Property
- %w[to_node from_node].each do |direction|
+ %w(to_node from_node).each do |direction|
define_method("#{direction}") { instance_variable_get("@#{direction}") }
define_method("#{direction}=") do |argument|
- raise FrozenRelError, 'Relationship start/end nodes cannot be changed once persisted' if self.persisted?
+ fail FrozenRelError, 'Relationship start/end nodes cannot be changed once persisted' if self.persisted?
instance_variable_set("@#{direction}", argument)
end
end
alias_method :start_node, :from_node
@@ -32,26 +32,34 @@
attributes.keys.each_with_object({}) do |key, relationship_props|
relationship_props[key] = attributes.delete(key) if [:from_node, :to_node].include?(key)
end
end
- %w[to_class from_class].each do |direction|
+ %w(to_class from_class).each do |direction|
define_method("#{direction}") { |argument| instance_variable_set("@#{direction}", argument) }
define_method("_#{direction}") { instance_variable_get "@#{direction}" }
end
alias_method :start_class, :from_class
alias_method :end_class, :to_class
def load_entity(id)
Neo4j::Node.load(id)
end
+
+ def creates_unique_rel
+ @unique = true
+ end
+
+ def unique?
+ !!@unique
+ end
end
private
def load_nodes(from_node = nil, to_node = nil)
@from_node = RelatedNode.new(from_node)
@to_node = RelatedNode.new(to_node)
end
end
-end
\ No newline at end of file
+end