Class: ROX::SimpleModule
- Inherits:
-
Object
show all
- Defined in:
- lib/rox/simple_module.rb
Instance Method Summary
collapse
Constructor Details
#initialize(path, client) ⇒ SimpleModule
Returns a new instance of SimpleModule.
4
5
6
7
|
# File 'lib/rox/simple_module.rb', line 4
def initialize(path, client)
@path = path
@client = client
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
35
36
37
38
|
# File 'lib/rox/simple_module.rb', line 35
def method_missing(meth, *args, &block)
params = args.first || {}
_call(meth, params)
end
|
Instance Method Details
#_call(action, params) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/rox/simple_module.rb', line 21
def _call(action, params)
params[:action] = action
if(params[:body])
params[:body] = params[:body].to_json
_put(params)
elsif params[:body_raw]
params[:body] = params[:body_raw]
params.delete(:body_raw)
_put(params)
else
_get(params)
end
end
|
#_get(params) ⇒ Object
9
10
11
|
# File 'lib/rox/simple_module.rb', line 9
def _get(params)
@client.get_response(@path, params)
end
|
#_put(params) ⇒ Object
13
14
15
|
# File 'lib/rox/simple_module.rb', line 13
def _put(params)
@client.put_response(@path, params)
end
|
#call(action, params) ⇒ Object
17
18
19
|
# File 'lib/rox/simple_module.rb', line 17
def call(action, params)
_call(action, params)
end
|