Module: Mongoid::Document::PickleAdapter

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

Class Method Summary (collapse)

Methods included from Pickle::Adapter::Base

adapters, included

Class Method Details

+ (Object) column_names(klass)

get a list of column names for a given class



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

def self.column_names(klass)
  klass.try(:fields).try(:keys) || []
end

+ (Object) create_model(klass, attributes)

Create a model with given attributes



39
40
41
# File 'lib/pickle/adapters/mongoid.rb', line 39

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

+ (Object) except_classes

Do not consider these to be part of the class list



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

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

+ (Object) find_all_models(klass, conditions)

Find all models matching conditions



34
35
36
# File 'lib/pickle/adapters/mongoid.rb', line 34

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

+ (Object) find_first_model(klass, conditions)

Find the first instance matching conditions



29
30
31
# File 'lib/pickle/adapters/mongoid.rb', line 29

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

+ (Object) get_model(klass, id)

Get an instance by id of the model



24
25
26
# File 'lib/pickle/adapters/mongoid.rb', line 24

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

+ (Object) model_classes

Gets a list of the available models for this adapter



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

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