Class: Unimatrix::Authorization::Operation
- Inherits:
-
Operation
- Object
- Operation
- Unimatrix::Authorization::Operation
show all
- Defined in:
- lib/unimatrix/authorization/operation.rb
Instance Method Summary
collapse
Methods inherited from Operation
#include, #initialize, #key, #limit, #offset, #read_in_batches, #where
Instance Method Details
#destroy ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/unimatrix/authorization/operation.rb', line 4
def destroy
result = nil
Request.new.tap do | request |
response = request.destroy( @path, @parameters )
if response_is_error?( response )
result = response
elsif response.present?
result = response.resources
end
end
result
end
|
#read(&block) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/unimatrix/authorization/operation.rb', line 17
def read( &block )
result = nil
response = nil
Request.new.tap do | request |
request.get( @path, @parameters ).tap do | response |
if response_is_error?( response )
result = response
else
result = response.resources
if block_given?
case block.arity
when 0; yield
when 1; yield result
when 2; yield result, response
end
end
end
end
end
result
end
|
#write(node, objects, &block) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/unimatrix/authorization/operation.rb', line 39
def write( node, objects, &block )
result = nil
Request.new.tap do | request |
serializer = Unimatrix::Serializer.new( objects )
response = request.post( @path, @parameters, serializer.serialize( node ) )
if response_is_error?( response )
result = response
else
result = response.resources
if block_given?
case block.arity
when 0; yield
when 1; yield result
when 2; yield result, response
end
end
end
end
result
end
|