Class: DataMapper::Repository
Defined Under Namespace
Modules: Migration, Transaction
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#transaction
Methods included from Migration
#auto_migrate!, #auto_upgrade!, #map, #migrate!, #storage_exists?, #type_map
Methods included from Assertions
#assert_kind_of
Instance Attribute Details
Returns the value of attribute name.
22
23
24
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 22
def name
@name
end
|
Class Method Details
._load(marshalled) ⇒ Object
98
99
100
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 98
def self._load(marshalled)
new(marshalled.to_sym)
end
|
.adapters ⇒ Adapter
Returns the adapters registered for this repository.
10
11
12
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 10
def self.adapters
@adapters
end
|
14
15
16
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 14
def self.context
Thread.current[:dm_repository_contexts] ||= []
end
|
.default_name ⇒ Object
18
19
20
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 18
def self.default_name
:default
end
|
Instance Method Details
94
95
96
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 94
def _dump(*)
name.to_s
end
|
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 24
def adapter
@adapter ||= begin
raise ArgumentError, "Adapter not set: #{@name}. Did you forget to setup?" \
unless self.class.adapters.has_key?(@name)
self.class.adapters[@name]
end
end
|
#aggregate(query) ⇒ Object
3
4
5
|
# File 'lib/gems/dm-aggregates-0.9.9/lib/dm-aggregates/repository.rb', line 3
def aggregate(query)
adapter.aggregate(query)
end
|
#create(resources) ⇒ Object
50
51
52
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 50
def create(resources)
adapter.create(resources)
end
|
#delete(query) ⇒ Object
79
80
81
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 79
def delete(query)
adapter.delete(query)
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
83
84
85
86
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 83
def eql?(other)
return true if super
name == other.name
end
|
#identity_map(model) ⇒ Object
35
36
37
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 35
def identity_map(model)
@identity_maps[model] ||= IdentityMap.new
end
|
retrieve a collection of results of a query
60
61
62
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 60
def read_many(query)
adapter.read_many(query)
end
|
retrieve a resource instance by a query
71
72
73
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 71
def read_one(query)
adapter.read_one(query)
end
|
40
41
42
43
44
45
46
47
48
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 40
def scope
Repository.context << self
begin
return yield(self)
ensure
Repository.context.pop
end
end
|
90
91
92
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 90
def to_s
"#<DataMapper::Repository:#{@name}>"
end
|
#update(attributes, query) ⇒ Object
75
76
77
|
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/repository.rb', line 75
def update(attributes, query)
adapter.update(attributes, query)
end
|