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
#name ⇒ Object
Returns the value of attribute name.
22
23
24
|
# File 'lib/dm-core/repository.rb', line 22
def name
@name
end
|
Class Method Details
._load(marshalled) ⇒ Object
98
99
100
|
# File '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/dm-core/repository.rb', line 10
def self.adapters
@adapters
end
|
.context ⇒ Object
14
15
16
|
# File 'lib/dm-core/repository.rb', line 14
def self.context
Thread.current[:dm_repository_contexts] ||= []
end
|
.default_name ⇒ Object
18
19
20
|
# File 'lib/dm-core/repository.rb', line 18
def self.default_name
:default
end
|
Instance Method Details
#_dump ⇒ Object
94
95
96
|
# File 'lib/dm-core/repository.rb', line 94
def _dump(*)
name.to_s
end
|
#adapter ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File '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
|
#create(resources) ⇒ Object
50
51
52
|
# File 'lib/dm-core/repository.rb', line 50
def create(resources)
adapter.create(resources)
end
|
#delete(query) ⇒ Object
79
80
81
|
# File '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/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/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/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/dm-core/repository.rb', line 71
def read_one(query)
adapter.read_one(query)
end
|
#scope ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/dm-core/repository.rb', line 40
def scope
Repository.context << self
begin
return yield(self)
ensure
Repository.context.pop
end
end
|
#to_s ⇒ Object
90
91
92
|
# File 'lib/dm-core/repository.rb', line 90
def to_s
"#<DataMapper::Repository:#{@name}>"
end
|
#update(attributes, query) ⇒ Object
75
76
77
|
# File 'lib/dm-core/repository.rb', line 75
def update(attributes, query)
adapter.update(attributes, query)
end
|