Sha256: 279d612b11cc36497e0a0766ae9a34b82bfcda5b93aa05ce1d3c14823d245717

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'orm_adapter'

module Neo4j
	module Rails
		class Model
			extend ::OrmAdapter::ToAdapter

			class OrmAdapter < ::OrmAdapter::Base
				# Do not consider these to be part of the class list
				def self.except_classes
					@@except_classes ||= []
				end

				# Gets a list of the available models for this adapter
				def self.model_classes
					::Neo4j::Rails::Model.descendants.to_a.select{|k| !except_classes.include?(k.name)}
				end

				# get a list of column names for a given class
				def column_names
					klass._decl_props.keys
				end

				# Get an instance by id of the model
				def get!(id)
					klass.find!(wrap_key(id))
				end

				# Get an instance by id of the model
				def get(id)
					klass.find(wrap_key(id))
				end

				# Find the first instance matching conditions
				def find_first(conditions)
					klass.first(conditions)
				end

				# Find all models matching conditions
				def find_all(conditions)
					klass.all(conditions)
				end

				# Create a model using attributes
				def create!(attributes)
					klass.create!(attributes)
				end
			end
		end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
neo4j-2.0.0.alpha.5-java lib/orm_adapter/adapters/neo4j.rb
neo4j-2.0.0.alpha.4-java lib/orm_adapter/adapters/neo4j.rb
neo4j-2.0.0.alpha.3-java lib/orm_adapter/adapters/neo4j.rb
neo4j-1.3.1-java lib/orm_adapter/adapters/neo4j.rb
neo4j-1.3.0-java lib/orm_adapter/adapters/neo4j.rb
neo4j-1.2.6-java lib/orm_adapter/adapters/neo4j.rb
neo4j-1.2.5-java lib/orm_adapter/adapters/neo4j.rb
neo4j-1.2.4-java lib/orm_adapter/adapters/neo4j.rb