Skip to content

Commit

Permalink
use labels instead of is_a? to determine whether nodes are of appropr…
Browse files Browse the repository at this point in the history
…iate type
  • Loading branch information
subvertallchris committed Jun 19, 2015
1 parent 05378f2 commit 3ed32c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/neo4j/active_node/query/query_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _nodeify!(*args)
(arg.is_a?(Integer) || arg.is_a?(String)) ? @model.find_by(@model.id_property_name => arg) : arg
end.compact

if @model && other_nodes.any? { |other_node| !other_node.is_a?(@model) }
if @model && other_nodes.any? { |other_node| !other_node.class.mapped_label_names.include?(@model.mapped_label_name) }
fail ArgumentError, "Node must be of the association's class when model is specified"
end

Expand Down
4 changes: 3 additions & 1 deletion lib/neo4j/active_rel/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def validate_node_classes!

next if [:any, false].include?(type_class)

fail ModelClassInvalidError, "Node class was #{node.class}, expected #{type_class}" unless node.is_a?(type_class.to_s.constantize)
unless node.class.mapped_label_names.include?(type_class.to_s.constantize.mapped_label_name)
fail ModelClassInvalidError, "Node class was #{node.class}, expected #{type_class}"
end
end
end

Expand Down

0 comments on commit 3ed32c7

Please sign in to comment.