Class: Ant::Server::Nanoservice::Datasource::Sequel
- Inherits:
-
Repository
- Object
- Repository
- Ant::Server::Nanoservice::Datasource::Sequel
show all
- Defined in:
- lib/ant/server/nanoservice/datasource/sequel.rb
Instance Method Summary
collapse
Methods inherited from Repository
#create, #create_initial_object, #exist?
Constructor Details
#initialize(sequel_object, id, id_generator) ⇒ Sequel
Returns a new instance of Sequel.
8
9
10
11
|
# File 'lib/ant/server/nanoservice/datasource/sequel.rb', line 8
def initialize(sequel_object, id, id_generator)
@sequel = sequel_object
super(id, id_generator)
end
|
Instance Method Details
#connection ⇒ Object
31
32
33
|
# File 'lib/ant/server/nanoservice/datasource/sequel.rb', line 31
def connection
@sequel
end
|
#create_(data) ⇒ Object
19
20
21
22
23
|
# File 'lib/ant/server/nanoservice/datasource/sequel.rb', line 19
def create_(data)
id = @sequel.insert(data)
data[@id] ||= id
data
end
|
#get(id) ⇒ Object
13
14
15
16
17
|
# File 'lib/ant/server/nanoservice/datasource/sequel.rb', line 13
def get(id)
result = @sequel.where(@id => id).first
raise(ObjectNotFound, id) if result.nil?
result
end
|
#store(data) ⇒ Object
25
26
27
28
29
|
# File 'lib/ant/server/nanoservice/datasource/sequel.rb', line 25
def store(data)
data2 = data.dup
data2.delete(@id)
@sequel.where(@id => data[@id]).update(data2)
end
|