Method: Neo4j::Wrapper::NodeMixin::ClassMethods#unique_factory_key

Defined in:
lib/neo4j-wrapper/node_mixin/class_methods.rb

#unique_factory_keySymbol?

Returns the property which has an unique index or nil.

Returns:

  • (Symbol, nil)

    the property which has an unique index or nil



73
74
75
76
77
78
79
80
81
# File 'lib/neo4j-wrapper/node_mixin/class_methods.rb', line 73

def unique_factory_key
  @unique_factory_key ||= begin
    unique = []
    _decl_props.each_pair { |k, v| unique << k if v[:unique] }
    return nil if unique.empty?
    raise "Only one property can be unique, got #{unique.join(', ')}" if unique.size > 1
    unique.first
  end
end