Class: Dock::DataMapper

Inherits:
Base
  • Object
show all
Defined in:
lib/dock/adapters/datamapper.rb

Instance Attribute Summary

Attributes inherited from Base

#model

Instance Method Summary collapse

Methods inherited from Base

#embedded, inherited, #initialize, #scoped

Constructor Details

This class inherits a constructor from Dock::Base

Instance Method Details

#all(options = {}) ⇒ Object

Checked



18
19
20
21
22
23
24
# File 'lib/dock/adapters/datamapper.rb', line 18

def 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?
    model.all opts
end

#associationsObject



43
44
45
# File 'lib/dock/adapters/datamapper.rb', line 43

def associations()

end

#belongs_toObject



60
61
62
# File 'lib/dock/adapters/datamapper.rb', line 60

def belongs_to()

end

#column_namesObject

Checked



50
51
52
# File 'lib/dock/adapters/datamapper.rb', line 50

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

#count(options = {}) ⇒ Object

Checked



54
55
56
# File 'lib/dock/adapters/datamapper.rb', line 54

def count(options = {})
  all(options).count
end

#create(attributes = {}) ⇒ Object

Checked



6
7
8
# File 'lib/dock/adapters/datamapper.rb', line 6

def create(attributes = {})
    model.create(attributes)
end

#cyclic?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/dock/adapters/datamapper.rb', line 72

def cyclic?
  false
end

#destroy(object) ⇒ Object

Checked



40
41
42
# File 'lib/dock/adapters/datamapper.rb', line 40

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

#embedded?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/dock/adapters/datamapper.rb', line 69

def embedded?
  true
end

#encodingObject



57
58
59
# File 'lib/dock/adapters/datamapper.rb', line 57

def encoding
  'UTF-8'
end

#find(id) ⇒ Object

Checked



10
11
12
# File 'lib/dock/adapters/datamapper.rb', line 10

def find(id)
  model.get(id)
end

#find!(id) ⇒ Object

Checked



14
15
16
# File 'lib/dock/adapters/datamapper.rb', line 14

def find!(id)
  model.get!(id)
end

#first(options = {}) ⇒ Object

Checked



26
27
28
29
# File 'lib/dock/adapters/datamapper.rb', line 26

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

#has_manyObject



63
64
65
# File 'lib/dock/adapters/datamapper.rb', line 63

def has_many()

end

#idObject

Checked



31
32
33
# File 'lib/dock/adapters/datamapper.rb', line 31

def id
    # not supported?
end

#model_nameObject



46
47
48
# File 'lib/dock/adapters/datamapper.rb', line 46

def model_name
  model.class.name
end

#propertiesObject



79
80
81
# File 'lib/dock/adapters/datamapper.rb', line 79

def properties()

end

#scoped?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/dock/adapters/datamapper.rb', line 66

def scoped?
  true
end

#supports_joins?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/dock/adapters/datamapper.rb', line 75

def supports_joins?
  false
end

#update(search_key, find_by, update_key, by_value) ⇒ Object

not supported?



34
35
36
37
38
# File 'lib/dock/adapters/datamapper.rb', line 34

def update(search_key, find_by, update_key, by_value)
  entry = all(search_key find_by)
  entry.attributes = {update_key => by_value}
  entry.save
end