Module: Orientdb4r::OClass

Defined in:
lib/orientdb4r/rest/model.rb

Overview

This module represents API to OrientDB’s class.

Instance Method Summary collapse

Instance Method Details

#clustersObject

Gets clusters of the class.



54
55
56
# File 'lib/orientdb4r/rest/model.rb', line 54

def clusters
  get_mandatory_attribute :clusters
end

#default_clusterObject

Gets the default cluster.



60
61
62
# File 'lib/orientdb4r/rest/model.rb', line 60

def default_cluster
  get_mandatory_attribute :defaultCluster
end

#nameObject

Gets name of the class.



25
26
27
# File 'lib/orientdb4r/rest/model.rb', line 25

def name
  get_mandatory_attribute :name
end

#propertiesObject

Gets properties of the class. Returns nil for a class without properties.



32
33
34
# File 'lib/orientdb4r/rest/model.rb', line 32

def properties
  self['properties']
end

#property(name) ⇒ Object

Gets a property with the given name.

Raises:

  • (ArgumentError)


38
39
40
41
42
43
44
# File 'lib/orientdb4r/rest/model.rb', line 38

def property(name)
  raise ArgumentError, 'no properties defined on class' if properties.nil?
  props = properties.select { |i| i['name'] == name.to_s }
  raise ::ArgumentError, "unknown property, name=#{name}" if props.empty?
  raise ::ArgumentError, "too many properties found, name=#{name}" if props.size > 1 # just to be sure
  props[0]
end

#super_classObject

Gets the super-class.



48
49
50
# File 'lib/orientdb4r/rest/model.rb', line 48

def super_class
  get_mandatory_attribute :superClass
end