Class: SmoothOperator::Operator::RemoteCall
- Inherits:
-
Object
- Object
- SmoothOperator::Operator::RemoteCall
show all
- Defined in:
- lib/smooth_operator/operator/remote_call.rb
Constant Summary
collapse
- HTTP_SUCCESS_CODES =
[200, 201, 202, 203, 204]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
77
78
79
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 77
def method_missing(method, *args, &block)
response.send(method, *args, &block)
end
|
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
8
9
10
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 8
def exception
@exception
end
|
#parsed_response ⇒ Object
Returns the value of attribute parsed_response.
8
9
10
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 8
def parsed_response
@parsed_response
end
|
#protocol_handler ⇒ Object
Returns the value of attribute protocol_handler.
8
9
10
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 8
def protocol_handler
@protocol_handler
end
|
#raw_response ⇒ Object
Returns the value of attribute raw_response.
8
9
10
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 8
def raw_response
@raw_response
end
|
#response ⇒ Object
34
35
36
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 34
def response
exception.present? ? false : @response
end
|
Instance Method Details
#<<(object) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 42
def <<(object)
if response.is_a? Array
response << object
else
response += object
end
end
|
#==(object_to_compare) ⇒ Object
38
39
40
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 38
def ==(object_to_compare)
response == object_to_compare
end
|
#code ⇒ Object
TO BE OVERWRITTEN IF NECESSARY
21
22
23
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 21
def code
@raw_response.code
end
|
#error? ⇒ Boolean
27
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 27
def error?; !ok? && exception.present?; end
|
#get_attributes(key, attributes = nil) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 58
def get_attributes(key, attributes = nil)
attributes ||= @parsed_response
if attributes.kind_of?(Hash)
attributes.include?(key) ? attributes[key] : attributes
else
attributes
end
end
|
#ok? ⇒ Boolean
25
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 25
def ok?; successful_response?; end
|
#parse_response ⇒ Object
TO BE OVERWRITTEN IF NECESSARY
13
14
15
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 13
def parse_response
@raw_response
end
|
#respond_to?(symbol, include_priv = false) ⇒ Boolean
50
51
52
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 50
def respond_to?(symbol, include_priv = false)
response.respond_to?(symbol, include_priv)
end
|
#successful_response? ⇒ Boolean
TO BE OVERWRITTEN IF NECESSARY
17
18
19
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 17
def successful_response?
@raw_response.blank? || HTTP_SUCCESS_CODES.include?(code)
end
|
#to_s ⇒ Object
54
55
56
|
# File 'lib/smooth_operator/operator/remote_call.rb', line 54
def to_s
response
end
|