class ActiveGraph::Node::OrmAdapter
Public Instance Methods
column_names()
click to toggle source
# File lib/active_graph/node/orm_adapter.rb 14 def column_names 15 klass._decl_props.keys 16 end
create!(attributes = {})
click to toggle source
Create a model using attributes
# File lib/active_graph/node/orm_adapter.rb 59 def create!(attributes = {}) 60 klass.create!(attributes) 61 end
destroy(object)
click to toggle source
@see OrmAdapter::Base#destroy
# File lib/active_graph/node/orm_adapter.rb 64 def destroy(object) 65 object.destroy && true if valid_object?(object) 66 end
find_all(options = {})
click to toggle source
Find all models matching conditions
# File lib/active_graph/node/orm_adapter.rb 46 def find_all(options = {}) 47 conditions, order, limit, offset = extract_conditions!(options) 48 extract_id!(conditions) 49 order = hasherize_order(order) 50 51 result = klass.where(conditions) 52 result = result.order(order) unless order.empty? 53 result = result.skip(offset) if offset 54 result = result.limit(limit) if limit 55 result.to_a 56 end
find_first(options = {})
click to toggle source
Find the first instance matching conditions
# File lib/active_graph/node/orm_adapter.rb 35 def find_first(options = {}) 36 conditions, order = extract_conditions!(options) 37 extract_id!(conditions) 38 order = hasherize_order(order) 39 40 result = klass.where(conditions) 41 result = result.order(order) unless order.empty? 42 result.first 43 end
get(id)
click to toggle source
Get an instance by id of the model
# File lib/active_graph/node/orm_adapter.rb 30 def get(id) 31 klass.find_by(klass.id_property_name => wrap_key(id)) 32 end
get!(id)
click to toggle source
Get an instance by id of the model
# File lib/active_graph/node/orm_adapter.rb 23 def get!(id) 24 klass.find(wrap_key(id)).tap do |node| 25 fail 'No record found' if node.nil? 26 end 27 end
i18n_scope()
click to toggle source
# File lib/active_graph/node/orm_adapter.rb 18 def i18n_scope 19 :neo4j 20 end
Private Instance Methods
extract_id!(conditions)
click to toggle source
# File lib/active_graph/node/orm_adapter.rb 74 def extract_id!(conditions) 75 id = conditions.delete(:id) 76 return if not id 77 78 conditions[klass.id_property_name.to_sym] = id 79 end
hasherize_order(order)
click to toggle source
# File lib/active_graph/node/orm_adapter.rb 70 def hasherize_order(order) 71 (order || []).map { |clause| Hash[*clause] } 72 end