Class: Neo4j::Schema::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/schema/operation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, property, options = default_options) ⇒ Operation

Returns a new instance of Operation.


6
7
8
9
10
11
12
13
14
15
# File 'lib/neo4j/schema/operation.rb', line 6

def initialize(label, property, options = default_options)
  @label = if label.is_a?(Neo4j::Core::Label)
             label
           else
             Neo4j::Core::Label.new(label, ActiveBase.current_session)
           end

  @property = property.to_sym
  @options = options
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label


4
5
6
# File 'lib/neo4j/schema/operation.rb', line 4

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options


4
5
6
# File 'lib/neo4j/schema/operation.rb', line 4

def options
  @options
end

#propertyObject (readonly)

Returns the value of attribute property


4
5
6
# File 'lib/neo4j/schema/operation.rb', line 4

def property
  @property
end

Class Method Details

.incompatible_operation_classesObject


17
18
19
# File 'lib/neo4j/schema/operation.rb', line 17

def self.incompatible_operation_classes
  []
end

Instance Method Details

#create!Object


25
26
27
28
29
# File 'lib/neo4j/schema/operation.rb', line 25

def create!
  drop_incompatible!
  return if exist?
  schema_query(:"create_#{type}")
end

#default_optionsObject


50
51
52
# File 'lib/neo4j/schema/operation.rb', line 50

def default_options
  {}
end

#drop!Object


35
36
37
# File 'lib/neo4j/schema/operation.rb', line 35

def drop!
  schema_query(:"drop_#{type}")
end

#drop_incompatible!Object


39
40
41
42
43
44
# File 'lib/neo4j/schema/operation.rb', line 39

def drop_incompatible!
  incompatible_operation_classes.each do |clazz|
    operation = clazz.new(@label, property)
    operation.drop! if operation.exist?
  end
end

#exist?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/neo4j/schema/operation.rb', line 46

def exist?
  fail 'Abstract class, not implemented'
end

#incompatible_operation_classesObject


31
32
33
# File 'lib/neo4j/schema/operation.rb', line 31

def incompatible_operation_classes
  self.class.incompatible_operation_classes
end

#label_objectObject


21
22
23
# File 'lib/neo4j/schema/operation.rb', line 21

def label_object
  label
end

#typeObject


54
55
56
# File 'lib/neo4j/schema/operation.rb', line 54

def type
  fail 'Abstract class, not implemented'
end