Class: Perry::Adapters::BERTRPCAdapter
Instance Attribute Summary
#config, #type
Instance Method Summary
collapse
#call, create, #execute, #extend_adapter, #initialize, #middlewares, #processors, register_as
Methods included from Logger
included
Instance Method Details
#delete(options) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/perry/adapters/bertrpc_adapter.rb', line 41
def delete(options)
query = options.dup
object = query.delete(:object)
if object
query[:where] = self.where_for_primary_key(object)
end
log(query, "RPC #{config[:service]}") {
self.parse_response(self.call_server(query))
}
end
|
#read(options) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/perry/adapters/bertrpc_adapter.rb', line 14
def read(options)
query = options[:relation].to_hash
query[:mode] = :read
log(query, "RPC #{config[:service]}") {
self.call_server(query)
}
end
|
#service ⇒ Object
9
10
11
12
|
# File 'lib/perry/adapters/bertrpc_adapter.rb', line 9
def service
@@service_pool["#{config[:host]}:#{config[:port]}"] ||=
BERTRPC::Service.new(self.config[:host], self.config[:port])
end
|
#write(options) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/perry/adapters/bertrpc_adapter.rb', line 22
def write(options)
query = options.dup
object = query.delete(:object)
if object
query[:fields] = object.attributes
if object.new_record?
query[:mode] = :create
else
query[:mode] = :update
query[:where] = self.where_for_primary_key(object)
end
else
query[:mode] = :update
end
log(query, "RPC #{config[:service]}") {
self.parse_response(self.call_server(query))
}
end
|