Class: Neo4j::Server::CypherLabel

Inherits:
Label
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/neo4j-server/cypher_label.rb

Constant Summary

Constants inherited from Label

Label::CONSTRAINT_PATH, Label::INDEX_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Label

constraint?, constraints, create, #create_constraint, drop_all_constraints, drop_all_indexes, #drop_constraint, find_all_nodes, find_nodes, index?, indexes

Constructor Details

#initialize(session, name) ⇒ CypherLabel

Returns a new instance of CypherLabel.



8
9
10
11
# File 'lib/neo4j-server/cypher_label.rb', line 8

def initialize(session, name)
  @name = name
  @session = session
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/neo4j-server/cypher_label.rb', line 6

def name
  @name
end

Instance Method Details

#create_index(property, options = {}, session = Neo4j::Session.current) ⇒ Object



13
14
15
16
17
18
# File 'lib/neo4j-server/cypher_label.rb', line 13

def create_index(property, options = {}, session = Neo4j::Session.current)
  validate_index_options!(options)
  properties = property.is_a?(Array) ? property.join(',') : property
  response = session._query("CREATE INDEX ON :`#{@name}`(#{properties})")
  response.raise_error if response.error?
end

#drop_index(property, options = {}, session = Neo4j::Session.current) ⇒ Object



20
21
22
23
24
# File 'lib/neo4j-server/cypher_label.rb', line 20

def drop_index(property, options = {}, session = Neo4j::Session.current)
  validate_index_options!(options)
  response = session._query("DROP INDEX ON :`#{@name}`(#{property})")
  response.raise_error if response.error? && !response.error_msg.match(/No such INDEX ON/)
end

#indexesObject



26
27
28
# File 'lib/neo4j-server/cypher_label.rb', line 26

def indexes
  @session.indexes(@name)
end

#uniqueness_constraintsObject



30
31
32
# File 'lib/neo4j-server/cypher_label.rb', line 30

def uniqueness_constraints
  @session.uniqueness_constraints(@name)
end