Class: ActiveOrient::Model

Inherits:
Base
  • Object
show all
Extended by:
ModelClass
Includes:
BaseProperties, ModelRecord
Defined in:
lib/model/model.rb

Direct Known Subclasses

Query, E, V

Constant Summary

Constants included from OrientDB

OrientDB::DocumentDatabase, OrientDB::DocumentDatabasePool, OrientDB::DocumentDatabasePooled, OrientDB::GraphDatabase, OrientDB::IndexType, OrientDB::OClassImpl, OrientDB::OTraverse, OrientDB::PropertyImpl, OrientDB::RemoteStorage, OrientDB::SQLCommand, OrientDB::SQLSynchQuery, OrientDB::Schema, OrientDB::SchemaProxy, OrientDB::SchemaType, OrientDB::ServerAdmin, OrientDB::User, OrientDB::UsingJava

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModelClass

add_edge_link, all, alter_property, classname, count, create, create_index, create_properties, create_property, custom_where, delete_property, delete_record, delete_records, first, get, get_model_class, get_properties, get_records, last, match, naming_convention, orientdb_class, print_class_properties, query_database, require_model_file, superClass, update_or_create_records, update_records, upsert, where

Methods included from ModelRecord

#add_item_to_property, classname, #find, #from_orient, #increment_version, #is_edge?, #method_missing, #query, #reload!, #remove, #remove_item_from_property, #rid, #rrid, #save, #set_item_to_property, #to_or, #update, #update_item_property, #version, #version=

Methods included from BaseProperties

#==, #content_attributes, #default_attributes, #set_attribute_defaults, #to_human, #update_missing

Methods inherited from Base

#[], #[]=, attr_accessible, attr_protected, #attributes, #attributes=, display_rid, get_rid, #initialize, remove_rid, serialize, store_rid, #to_model, #update_attribute

Constructor Details

This class inherits a constructor from ActiveOrient::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ModelRecord

Class Attribute Details

.abstractObject

Returns the value of attribute abstract.



74
75
76
# File 'lib/model/model.rb', line 74

def abstract
  @abstract
end

.ref_nameObject

Returns the value of attribute ref_name.



73
74
75
# File 'lib/model/model.rb', line 73

def ref_name
  @ref_name
end

Instance Attribute Details

#metadataObject (readonly)

Used to read the metadata



68
69
70
# File 'lib/model/model.rb', line 68

def 
  
end

Class Method Details

.autoload_object(rid) ⇒ Object

Example:

ActiveOrient::Model.autoload_object "#00:00"

either retrieves the object from the rid_store or loads it from the DB.

The rid_store is updated!

To_do: fetch for version in the db and load the object if a change is detected

Note: This function is not in ModelClass since it needs to use @@rid_store



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/model/model.rb', line 24

def self.autoload_object rid
  rid = rid[1..-1] if rid[0]=='#'
  if rid.rid?
  if  @@rid_store[rid].present?
    @@rid_store[rid]  # return_value
  else
db.get_record(rid)
  end
  else
    logger.progname = "ActiveOrient::Model#AutoloadObject"
    logger.info{"#{rid} is not a valid rid."}
  end
end

.delete_classObject

Deletes the database class and removes the ruby-class



50
51
52
53
54
# File 'lib/model/model.rb', line 50

def self.delete_class
  orientdb.delete_class self
  ## namespace is defined in config/boot
  namespace.send(:remove_const, naming_convention.to_sym)
end

Instance Method Details

#documentObject

:nodoc:



43
44
45
# File 'lib/model/model.rb', line 43

def document  # :nodoc:
  @d
end

#to_aryObject

to prevent errors when calling to_a



39
40
41
# File 'lib/model/model.rb', line 39

def to_ary   # :nodoc:
  attributes.to_a
end