Module: DataMapper::Resource::PickleAdapter
- Includes:
- Pickle::Adapter::Base
- Defined in:
- lib/pickle/adapters/data_mapper.rb
Class Method Summary (collapse)
-
+ (Object) column_names(klass)
get a list of column names for a given class.
-
+ (Object) create_model(klass, attributes)
Create a model using attributes.
-
+ (Object) except_classes
Do not consider these to be part of the class list.
-
+ (Object) find_all_models(klass, conditions)
Find all models matching conditions.
-
+ (Object) find_first_model(klass, conditions)
Find the first instance matching conditions.
-
+ (Object) get_model(klass, id)
Get an instance by id of the model.
-
+ (Object) model_classes
Gets a list of the available models for this adapter.
Methods included from Pickle::Adapter::Base
Class Method Details
+ (Object) column_names(klass)
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 |
+ (Object) create_model(klass, attributes)
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 |
+ (Object) except_classes
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 |
+ (Object) find_all_models(klass, conditions)
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 |
+ (Object) find_first_model(klass, conditions)
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 |
+ (Object) get_model(klass, id)
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 |
+ (Object) model_classes
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 |