get a list of column names for a given class
# File lib/pickle/adapters/data_mapper.rb, line 18 def self.column_names(klass) klass.properties.map(&:name) end
Create a model using attributes
# File lib/pickle/adapters/data_mapper.rb, line 38 def self.create_model(klass, attributes) klass.create(attributes) end
Do not consider these to be part of the class list
# File lib/pickle/adapters/data_mapper.rb, line 8 def self.except_classes @@except_classes ||= [] end
Find all models matching conditions
# File lib/pickle/adapters/data_mapper.rb, line 33 def self.find_all_models(klass, conditions) klass.all(conditions) end
Find the first instance matching conditions
# File lib/pickle/adapters/data_mapper.rb, line 28 def self.find_first_model(klass, conditions) klass.first(conditions) end
Get an instance by id of the model
# File lib/pickle/adapters/data_mapper.rb, line 23 def self.get_model(klass, id) klass.get(id) end
Gets a list of the available models for this adapter
# 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