Class: Facebooker::BatchRequest
- Inherits:
-
Object
- Object
- Facebooker::BatchRequest
show all
- Defined in:
- lib/facebooker/batch_request.rb
Defined Under Namespace
Classes: UnexecutedRequest
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params, proc) ⇒ BatchRequest
Returns a new instance of BatchRequest.
7
8
9
10
11
12
13
|
# File 'lib/facebooker/batch_request.rb', line 7
def initialize(params,proc)
@exception = nil
@result = nil
@method = params[:method]
@uri = params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
@proc = proc
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &proc) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/facebooker/batch_request.rb', line 35
def method_missing(name,*args,&proc)
if @exception
raise @exception
elsif @result.nil?
raise UnexecutedRequest.new("You must execute the batch before accessing the result: #{@uri}")
else
@result.send(name,*args,&proc)
end
end
|
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
5
6
7
|
# File 'lib/facebooker/batch_request.rb', line 5
def method
@method
end
|
#uri ⇒ Object
Returns the value of attribute uri.
4
5
6
|
# File 'lib/facebooker/batch_request.rb', line 4
def uri
@uri
end
|
Instance Method Details
#===(other) ⇒ Object
31
32
33
|
# File 'lib/facebooker/batch_request.rb', line 31
def ===(other)
other === @result
end
|
#exception_raised=(ex) ⇒ Object
19
20
21
|
# File 'lib/facebooker/batch_request.rb', line 19
def exception_raised=(ex)
@exception=ex
end
|
#exception_raised? ⇒ Boolean
23
24
25
|
# File 'lib/facebooker/batch_request.rb', line 23
def exception_raised?
@exception.nil? ? false : raise(@exception)
end
|
#respond_to?(name) ⇒ Boolean
27
28
29
|
# File 'lib/facebooker/batch_request.rb', line 27
def respond_to?(name)
super || @result.respond_to?(name)
end
|
#result=(result_object) ⇒ Object
15
16
17
|
# File 'lib/facebooker/batch_request.rb', line 15
def result=(result_object)
@result = @proc.nil? ? result_object : @proc.call(result_object)
end
|