OrmAdapter¶
Constants¶
Methods¶
#column_names
def column_names klass._decl_props.keys end
- #create!
Create a model using attributes
def create!(attributes = {}) klass.create!(attributes) end
#destroy
def destroy(object) object.destroy && true if valid_object?(object) end
- #find_all
Find all models matching conditions
def find_all(options = {}) conditions, order, limit, offset = extract_conditions!(options) extract_id!(conditions) order = hasherize_order(order) result = klass.where(conditions) result = result.order(order) unless order.empty? result = result.skip(offset) if offset result = result.limit(limit) if limit result.to_a end
- #find_first
Find the first instance matching conditions
def find_first(options = {}) conditions, order = extract_conditions!(options) extract_id!(conditions) order = hasherize_order(order) result = klass.where(conditions) result = result.order(order) unless order.empty? result.first end
- #get
Get an instance by id of the model
def get(id) klass.find_by(klass.id_property_name => wrap_key(id)) end
- #get!
Get an instance by id of the model
def get!(id) klass.find(wrap_key(id)).tap do |node| fail 'No record found' if node.nil? end end
#i18n_scope
def i18n_scope :neo4j end