Module: DataMapper::Resource::PickleAdapter

Includes:
Pickle::Adapter::Base
Defined in:
lib/pickle/adapters/data_mapper.rb

Class Method Summary collapse

Methods included from Pickle::Adapter::Base

adapters, included

Class Method Details

.column_names(klass) ⇒ Object

get a list of column names for a given class



18
19
20
# File 'lib/pickle/adapters/data_mapper.rb', line 18

def self.column_names(klass)
  klass.properties.map(&:name)
end

.create_model(klass, attributes) ⇒ Object

Create a model using attributes



38
39
40
# File 'lib/pickle/adapters/data_mapper.rb', line 38

def self.create_model(klass, attributes)
  klass.create(attributes)
end

.except_classesObject

Do not consider these to be part of the class list



8
9
10
# File 'lib/pickle/adapters/data_mapper.rb', line 8

def self.except_classes
  @@except_classes ||= []
end

.find_all_models(klass, conditions) ⇒ Object

Find all models matching conditions



33
34
35
# File 'lib/pickle/adapters/data_mapper.rb', line 33

def self.find_all_models(klass, conditions)
  klass.all(conditions)
end

.find_first_model(klass, conditions) ⇒ Object

Find the first instance matching conditions



28
29
30
# File 'lib/pickle/adapters/data_mapper.rb', line 28

def self.find_first_model(klass, conditions)
  klass.first(conditions)
end

.get_model(klass, id) ⇒ Object

Get an instance by id of the model



23
24
25
# File 'lib/pickle/adapters/data_mapper.rb', line 23

def self.get_model(klass, id)
  klass.get(id)
end

.model_classesObject

Gets a list of the available models for this adapter



13
14
15
# File 'lib/pickle/adapters/data_mapper.rb', line 13

def self.model_classes
  ::DataMapper::Model.descendants.to_a.select{|k| !except_classes.include?(k.name)}
end