Class: CpanelApi::Response
- Inherits:
-
Object
- Object
- CpanelApi::Response
show all
- Defined in:
- lib/panelbeater/response.rb
Constant Summary
collapse
- @@response_types =
{
:applist => 'app',
:createacct => 'result',
:passwd => 'passwd'
}
Instance Method Summary
collapse
Constructor Details
#initialize(command, response) ⇒ Response
Returns a new instance of Response.
10
11
12
13
|
# File 'lib/panelbeater/response.rb', line 10
def initialize(command, response)
@command = command
@response = response
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
27
28
29
30
|
# File 'lib/panelbeater/response.rb', line 27
def method_missing(method, *args)
return(json[node_name].first[method.to_s]) if json[node_name].first.has_key?(method.to_s)
end
|
Instance Method Details
#code ⇒ Object
19
20
21
|
# File 'lib/panelbeater/response.rb', line 19
def code
@response.code
end
|
#json ⇒ Object
23
24
25
|
# File 'lib/panelbeater/response.rb', line 23
def json
JSON.parse @response.body
end
|
#success? ⇒ Boolean
15
16
17
|
# File 'lib/panelbeater/response.rb', line 15
def success?
json[node_name].first['status'] == 1
end
|