Class: Restfulie::Client::Dsl
- Inherits:
-
Object
- Object
- Restfulie::Client::Dsl
show all
- Defined in:
- lib/restfulie/client/dsl.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Dsl
Returns a new instance of Dsl.
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/restfulie/client/dsl.rb', line 4
def initialize
@requests = []
trait :base
trait :verb
request :base_request
request :rescue_exception
request :setup_header
request :serialize_body
request :enhance_response
request :follow_request
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/restfulie/client/dsl.rb', line 29
def method_missing(sym, *args)
if Restfulie::Client::Feature.const_defined? sym.to_s.classify
loaded = true
trait sym
end
if Restfulie::Client::Feature.const_defined? "#{sym.to_s.classify}Request"
loaded = true
request "#{sym.to_s}Request", *args
end
if loaded
self
else
super sym, *args
end
end
|
Instance Method Details
#request(what, *args) ⇒ Object
17
18
19
20
21
|
# File 'lib/restfulie/client/dsl.rb', line 17
def request(what, *args)
req = "Restfulie::Client::Feature::#{what.to_s.classify}".constantize
@requests << {:type => req, :args => args}
self
end
|
#request_flow(env = {}) ⇒ Object
#trait(sym) ⇒ Object
23
24
25
26
27
|
# File 'lib/restfulie/client/dsl.rb', line 23
def trait(sym)
t = "Restfulie::Client::Feature::#{sym.to_s.classify}".constantize
self.extend t
self
end
|