Class: Neo4j::Schema::Operation
- Inherits:
-
Object
- Object
- Neo4j::Schema::Operation
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_name, property, options = default_options) ⇒ Operation
Returns a new instance of Operation.
6
7
8
9
10
|
# File 'lib/neo4j/schema/operation.rb', line 6
def initialize(label_name, property, options = default_options)
@label_name = label_name.to_sym
@property = property.to_sym
@options = options
end
|
Instance Attribute Details
#label_name ⇒ Object
Returns the value of attribute label_name.
4
5
6
|
# File 'lib/neo4j/schema/operation.rb', line 4
def label_name
@label_name
end
|
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/neo4j/schema/operation.rb', line 4
def options
@options
end
|
#property ⇒ Object
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_classes ⇒ Object
12
13
14
|
# File 'lib/neo4j/schema/operation.rb', line 12
def self.incompatible_operation_classes
[]
end
|
Instance Method Details
#create! ⇒ Object
16
17
18
19
20
|
# File 'lib/neo4j/schema/operation.rb', line 16
def create!
drop_incompatible!
return if exist?
label_object.send(:"create_#{type}", property, options)
end
|
#default_options ⇒ Object
45
46
47
|
# File 'lib/neo4j/schema/operation.rb', line 45
def default_options
{}
end
|
#drop! ⇒ Object
30
31
32
|
# File 'lib/neo4j/schema/operation.rb', line 30
def drop!
label_object.send(:"drop_#{type}", property, options)
end
|
#drop_incompatible! ⇒ Object
34
35
36
37
38
39
|
# File 'lib/neo4j/schema/operation.rb', line 34
def drop_incompatible!
incompatible_operation_classes.each do |clazz|
operation = clazz.new(label_name, property)
operation.drop! if operation.exist?
end
end
|
#exist? ⇒ Boolean
41
42
43
|
# File 'lib/neo4j/schema/operation.rb', line 41
def exist?
fail 'Abstract class, not implemented'
end
|
#incompatible_operation_classes ⇒ Object
26
27
28
|
# File 'lib/neo4j/schema/operation.rb', line 26
def incompatible_operation_classes
self.class.incompatible_operation_classes
end
|
#label_object ⇒ Object
22
23
24
|
# File 'lib/neo4j/schema/operation.rb', line 22
def label_object
@label_object ||= Neo4j::Label.create(label_name)
end
|
#type ⇒ Object
49
50
51
|
# File 'lib/neo4j/schema/operation.rb', line 49
def type
fail 'Abstract class, not implemented'
end
|