Class: E
- Inherits:
-
ActiveOrient::Model
- Object
- ActiveOrient::Base
- ActiveOrient::Model
- E
- Defined in:
- lib/model/edge.rb
Overview
to do instead of creating a class, use a module which is included on startup then, after specifying the namespace and before autoaccolating the database-classes create the proper E-Base-class and include this stuff
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
Instance Attribute Summary
Attributes inherited from ActiveOrient::Model
Attributes inherited from ActiveOrient::Base
Class Method Summary collapse
- .create(**keyword_arguments) ⇒ Object
-
.delete(where:) ⇒ Object
Edge#delete fires a “delete edge” command to the database.
-
.uniq_index ⇒ Object
establish contrains on Edges.
Instance Method Summary collapse
-
#remove ⇒ Object
remove works on record-level.
Methods inherited from ActiveOrient::Model
autoload_object, delete_class, #document, #to_ary
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, #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_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 ActiveOrient::BaseProperties
#==, #content_attributes, #default_attributes, #set_attribute_defaults, #to_human, #update_missing
Methods inherited from ActiveOrient::Base
#[], #[]=, attr_accessible, attr_protected, #attributes, #attributes=, belongs_to, display_rid, #document, 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 Method Details
.create(**keyword_arguments) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/model/edge.rb', line 29 def create **keyword_arguments new_edge = db.create_edge self, **keyword_arguments new_edge = new_edge.pop if new_edge.is_a?( Array) && new_edge.size == 1 # to.reload! if to.is_a? ActiveOrient::Model # from.reload! if from.is_a? ActiveOrient::Model # vertices must be reloaded new_edge # returns the created edge (or an array of created edges end |
.delete(where:) ⇒ Object
Edge#delete fires a “delete edge” command to the database. The where statement can be empty ( “” or {}“), then all edges are removed
The rid-cache is reseted, too
45 46 47 48 |
# File 'lib/model/edge.rb', line 45 def delete where: db.execute { "delete edge #{ref_name} #{db.compose_where(where)}" } reset_rid_store end |
.uniq_index ⇒ Object
establish contrains on Edges
Edges are uniq!
Creates individual indices for child-classes if applied to the class itself.
14 15 16 17 18 |
# File 'lib/model/edge.rb', line 14 def uniq_index create_property :in, type: :link, linked_class: :V create_property :out, type: :link, linked_class: :V create_index "#{ref_name}_idx", on: [ :in, :out ] end |
Instance Method Details
#remove ⇒ Object
remove works on record-level
52 53 54 |
# File 'lib/model/edge.rb', line 52 def remove db.delete_edge self end |