Skip to content

Initialisation

topofocus edited this page Mar 29, 2019 · 19 revisions

ActivdeOrient requires a running OrientDB-Server-instance

ORD = ActiveOrient::Init.connect database: <temp>,
				user: <root>,
				password: <root>,
				server: <localhost>,
				port: <2480>,
				logger: <nil>

connects to the server, opens the database and gathers informations about server and database.

Base-Classes for Edges and Vertexes, E and V are allocated.

Preallocate Database Classes

The directive ActiveOrient::Model.keep_models_without_file controls the preallocation process.

  • If set to false, only database-classes with corresponding model-files are preallocated and assigned to their ActiveOrient::Modelclass.
  • If set to true, any database class present is allocated to a ActiveOrient::Modelclass.

Model-Dir

ActiveOrient::Model-Methods are stored in (root)/lib/modelby default.

The location is overwritten by

ActiveOrient::Model.model_dir = project_root + '/model'

A typical setup using the ActiveOrient Gem:

#(after ActiveOrient::Init.connect)
project_root = File.expand_path('../..', __FILE__)
ActiveOrient::Model.model_dir =  project_root + '/model'
ActiveOrient::OrientDB.new  preallocate: true 

Then model files are required from the model-directory of the application rather then the gem-root-dir.

Namespacing

ORD = ActiveOrient::Init.connect

project_root = File.expand_path('../..', __FILE__)
ActiveOrient::Model.model_dir =  project_root + '/model'
ActiveOrient::Model.keep_models_without_file = false

# allocate classes from /model directory
ActiveOrient::OrientDB.new  preallocate: true  

module HC; end
ActiveOrient::Init.define_namespace { HC }

# allocate classes from /model/hc directory
ActiveOrient::OrientDB.new  preallocate: true  

# allocate any other classes and use methods defined in /model/tg 
module TG; end
ActiveOrient::Init.define_namespace { TG } 
ActiveOrient::Model.keep_models_without_file = true
ActiveOrient::OrientDB.new  preallocate: true  

Clone this wiki locally