Class: DataMapper::Resource::OrmAdapter
Instance Attribute Summary
#klass
Class Method Summary
collapse
Instance Method Summary
collapse
inherited, #initialize
Class Method Details
.except_classes ⇒ Object
Do not consider these to be part of the class list
12
13
14
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 12
def self.except_classes
@@except_classes ||= []
end
|
.model_classes ⇒ Object
Gets a list of the available models for this adapter
17
18
19
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 17
def self.model_classes
::DataMapper::Model.descendants.to_a.select{|k| !except_classes.include?(k.name)}
end
|
Instance Method Details
#column_names ⇒ Object
get a list of column names for a given class
22
23
24
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 22
def column_names
klass.properties.map(&:name)
end
|
#create!(attributes = {}) ⇒ Object
49
50
51
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 49
def create!(attributes = {})
klass.create(attributes)
end
|
#destroy(object) ⇒ Object
54
55
56
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 54
def destroy(object)
object.destroy if valid_object?(object)
end
|
#find_all(options = {}) ⇒ Object
43
44
45
46
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 43
def find_all(options = {})
conditions, order = extract_conditions_and_order!(options)
klass.all :conditions => conditions, :order => order_clause(order)
end
|
#find_first(options = {}) ⇒ Object
37
38
39
40
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 37
def find_first(options = {})
conditions, order = extract_conditions_and_order!(options)
klass.first :conditions => conditions, :order => order_clause(order)
end
|
#get(id) ⇒ Object
32
33
34
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 32
def get(id)
klass.get(id)
end
|
#get!(id) ⇒ Object
27
28
29
|
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 27
def get!(id)
klass.get!(id)
end
|