Module: Mongoid::Document::PickleAdapter

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

Class Method Summary collapse

Class Method Details

.column_names(klass) ⇒ Object

get a list of column names for a given class



20
21
22
23
# File 'lib/pickle/adapters/mongoid.rb', line 20

def self.column_names(klass)
  #klass.column_names
  klass.fields.keys
end

.except_classesObject

Do not consider these to be part of the class list



10
11
12
# File 'lib/pickle/adapters/mongoid.rb', line 10

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

.find_all_models(klass, conditions) ⇒ Object

Find all models matching conditions



36
37
38
# File 'lib/pickle/adapters/mongoid.rb', line 36

def self.find_all_models(klass, conditions)
  klass.find(:all, :conditions => conditions)
end

.find_first_model(klass, conditions) ⇒ Object

Find the first instance matching conditions



31
32
33
# File 'lib/pickle/adapters/mongoid.rb', line 31

def self.find_first_model(klass, conditions)
  klass.find(:first, :conditions => conditions)
end

.get_model(klass, id) ⇒ Object

Get an instance by id of the model



26
27
28
# File 'lib/pickle/adapters/mongoid.rb', line 26

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

.model_classesObject

Gets a list of the available models for this adapter



15
16
17
# File 'lib/pickle/adapters/mongoid.rb', line 15

def self.model_classes
  @@model_classes ||= ObjectSpace.each_object(Class).select {|klass| klass.ancestors.include?(Mongoid::Document)}
end