Class: Pacer::Orient::OrientType

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pacer-orient/orient_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph, element_type, type) ⇒ OrientType

Returns a new instance of OrientType.



21
22
23
24
25
# File 'lib/pacer-orient/orient_type.rb', line 21

def initialize(graph, element_type, type)
  @graph = graph
  @element_type = type
  @type = type
end

Instance Attribute Details

#element_typeObject (readonly)

Returns the value of attribute element_type.



5
6
7
# File 'lib/pacer-orient/orient_type.rb', line 5

def element_type
  @element_type
end

#graphObject (readonly)

Returns the value of attribute graph.



5
6
7
# File 'lib/pacer-orient/orient_type.rb', line 5

def graph
  @graph
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/pacer-orient/orient_type.rb', line 5

def type
  @type
end

Instance Method Details

#drop_property!(name) ⇒ Object



68
69
70
71
72
# File 'lib/pacer-orient/orient_type.rb', line 68

def drop_property!(name)
  graph.send(:in_pure_transaction) do
    type.dropProperty name
  end
end

#indexed?(name) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/pacer-orient/orient_type.rb', line 35

def indexed?(name)
  p = property(name)
  p.indexed? if p
end

#indexed_propertiesObject



78
79
80
# File 'lib/pacer-orient/orient_type.rb', line 78

def indexed_properties
  type.indexedProperties.map { |p| Property.new self, p }
end

#inspectObject



82
83
84
85
86
# File 'lib/pacer-orient/orient_type.rb', line 82

def inspect
  abs = "Abstract" if abstract?
  strict = " (strict)" if strict_mode?
  "#<#{ abs }#{ type_name.capitalize }Type #{ name }#{ strict }>"
end

#propertiesObject



74
75
76
# File 'lib/pacer-orient/orient_type.rb', line 74

def properties
  type.properties.map { |p| Property.new self, p }
end

#property(name) ⇒ Object



40
41
42
43
# File 'lib/pacer-orient/orient_type.rb', line 40

def property(name)
  p = raw_property(name)
  Property.new self, p if p
end

#property!(name, otype) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/pacer-orient/orient_type.rb', line 45

def property!(name, otype)
  p = raw_property(name)
  unless p
    p = graph.send(:in_pure_transaction) do
      type.createProperty(name.to_s, graph.property_type(otype))
    end
  end
  Property.new self, p
end

#raw_property(name) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/pacer-orient/orient_type.rb', line 27

def raw_property(name)
  if name.is_a? Symbol or name.is_a? String
    type.getProperty name.to_s
  else
    name
  end
end

#set_super_class(sc) ⇒ Object



61
62
63
64
65
66
# File 'lib/pacer-orient/orient_type.rb', line 61

def set_super_class(sc)
  graph.send(:in_pure_transaction) do
    type.setSuperClass graph.orient_type(element_type, sc)
  end
  self
end

#super_classObject



55
56
57
58
59
# File 'lib/pacer-orient/orient_type.rb', line 55

def super_class
  if base_classes.any?
    OrientType.new graph, type.getSuperClass
  end
end