Class: DataMapper::Resource::OrmAdapter

Inherits:
OrmAdapter::Base show all
Defined in:
lib/orm_adapter/adapters/data_mapper.rb

Instance Attribute Summary

Attributes inherited from OrmAdapter::Base

#klass

Instance Method Summary collapse

Methods inherited from OrmAdapter::Base

inherited, #initialize

Constructor Details

This class inherits a constructor from OrmAdapter::Base

Instance Method Details

#column_namesObject

get a list of column names for a given class



11
12
13
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 11

def column_names
  klass.properties.map(&:name)
end

#create!(attributes = {}) ⇒ Object

See Also:

  • OrmAdapter::Base#create!


41
42
43
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 41

def create!(attributes = {})
  klass.create(attributes)
end

#destroy(object) ⇒ Object

See Also:

  • OrmAdapter::Base#destroy


46
47
48
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 46

def destroy(object)
  object.destroy if valid_object?(object)
end

#find_all(options = {}) ⇒ Object

See Also:

  • OrmAdapter::Base#find_all


32
33
34
35
36
37
38
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 32

def find_all(options = {})
  conditions, order, limit, offset = extract_conditions!(options)
  opts = { :conditions => conditions, :order => order_clause(order) }
  opts = opts.merge({ :limit => limit }) unless limit.nil?
  opts = opts.merge({ :offset => offset }) unless offset.nil?
  klass.all opts
end

#find_first(options = {}) ⇒ Object

See Also:

  • OrmAdapter::Base#find_first


26
27
28
29
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 26

def find_first(options = {})
  conditions, order = extract_conditions!(options)
  klass.first :conditions => conditions, :order => order_clause(order)
end

#get(id) ⇒ Object

See Also:

  • OrmAdapter::Base#get


21
22
23
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 21

def get(id)
  klass.get(id)
end

#get!(id) ⇒ Object

See Also:

  • OrmAdapter::Base#get!


16
17
18
# File 'lib/orm_adapter/adapters/data_mapper.rb', line 16

def get!(id)
  klass.get!(id)
end