Class: ActiveOrient::Model
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
-
.abstract ⇒ Object
Returns the value of attribute abstract.
-
.ref_name ⇒ Object
Returns the value of attribute ref_name.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Used to read the metadata.
Class Method Summary collapse
-
.autoload_object(rid) ⇒ Object
Example: ActiveOrient::Model.autoload_object “#00:00”.
-
.delete_class(what = :all) ⇒ Object
Deletes the database class and removes the ruby-class.
Instance Method Summary collapse
-
#document ⇒ Object
:nodoc:.
-
#to_ary ⇒ Object
to prevent errors when calling to_a.
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, remove, require_model_file, update_all, update_or_create_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, #remove_position_from_property, #rid, #rrid, #save, #set_item_to_property, #to_or, #update, #update_attribute, #update_attributes, #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=, belongs_to, display_rid, get_rid, has_many, has_one, #initialize, #my_metadata, remove_rid, reset_rid_store, 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
.abstract ⇒ Object
Returns the value of attribute abstract.
88 89 90 |
# File 'lib/model/model.rb', line 88 def abstract @abstract end |
.ref_name ⇒ Object
Returns the value of attribute ref_name.
87 88 89 |
# File 'lib/model/model.rb', line 87 def ref_name @ref_name end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Used to read the metadata
82 83 84 |
# File 'lib/model/model.rb', line 82 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_class(what = :all) ⇒ Object
Deletes the database class and removes the ruby-class
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/model/model.rb', line 50 def self.delete_class what= :all orientdb.delete_class( self ) if what == :all # remove the database-class ## namespace is defined in config/boot ns = namespace.to_s == 'Object' ? "" : namespace.to_s ns_found = -> ( a_class ) do to_compare = a_class.to_s.split(':') if ns == "" && to_compare.size == 1 true elsif to_compare.first == ns true else false end end self.allocated_classes.delete_if{|x,y| x == self.ref_name && ns_found[y]} if allocated_classes.is_a?(Hash) namespace.send(:remove_const, naming_convention.to_sym) if namespace.send( :const_defined?, naming_convention) end |
Instance Method Details
#document ⇒ Object
:nodoc:
43 44 45 |
# File 'lib/model/model.rb', line 43 def document # :nodoc: @d end |
#to_ary ⇒ Object
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 |