Class: Neo4j::Rails::Model::OrmAdapter
- Inherits:
-
OrmAdapter::Base
- Object
- OrmAdapter::Base
- Neo4j::Rails::Model::OrmAdapter
- Defined in:
- lib/orm_adapter/adapters/neo4j.rb
Class Method Summary (collapse)
-
+ (Object) except_classes
Do not consider these to be part of the class list.
-
+ (Object) model_classes
Gets a list of the available models for this adapter.
Instance Method Summary (collapse)
-
- (Object) column_names
get a list of column names for a given class.
-
- (Object) create!(attributes = {})
Create a model using attributes.
- - (Object) destroy(object)
-
- (Object) find_all(options = {})
Find all models matching conditions.
-
- (Object) find_first(options = {})
Find the first instance matching conditions.
-
- (Object) get(id)
Get an instance by id of the model.
-
- (Object) get!(id)
Get an instance by id of the model.
Class Method Details
+ (Object) except_classes
Do not consider these to be part of the class list
10 11 12 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 10 def self.except_classes @@except_classes ||= [] end |
+ (Object) model_classes
Gets a list of the available models for this adapter
15 16 17 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 15 def self.model_classes ::Neo4j::Rails::Model.descendants.to_a.select { |k| !except_classes.include?(k.name) } end |
Instance Method Details
- (Object) column_names
get a list of column names for a given class
20 21 22 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 20 def column_names klass._decl_props.keys end |
- (Object) create!(attributes = {})
Create a model using attributes
65 66 67 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 65 def create!(attributes = {}) klass.create!(attributes) end |
- (Object) destroy(object)
70 71 72 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 70 def destroy(object) object.destroy && true if valid_object?(object) end |
- (Object) find_all(options = {})
Find all models matching conditions
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 46 def find_all( = {}) conditions, order, limit, offset = extract_conditions!() result = if !order.empty? find_with_order(conditions, order) else klass.all(conditions) end if limit && offset result.drop(offset).first(limit) elsif limit result.first(limit) else result.to_a end end |
- (Object) find_first(options = {})
Find the first instance matching conditions
35 36 37 38 39 40 41 42 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 35 def find_first( = {}) conditions, order = extract_conditions!() if !order.empty? find_with_order(conditions, order).first else klass.first(conditions) end end |
- (Object) get(id)
Get an instance by id of the model
30 31 32 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 30 def get(id) klass.find(wrap_key(id)) end |
- (Object) get!(id)
Get an instance by id of the model
25 26 27 |
# File 'lib/orm_adapter/adapters/neo4j.rb', line 25 def get!(id) klass.find!(wrap_key(id)) end |