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
|
# File 'lib/facebooker/batch_request.rb', line 7
def initialize(params,proc)
@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
34
35
36
37
38
39
40
41
42
|
# File 'lib/facebooker/batch_request.rb', line 34
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
29
30
31
|
# File 'lib/facebooker/batch_request.rb', line 29
def ===(other)
other === @result
end
|
#exception_raised=(ex) ⇒ Object
17
18
19
|
# File 'lib/facebooker/batch_request.rb', line 17
def exception_raised=(ex)
@exception=ex
end
|
#exception_raised? ⇒ Boolean
21
22
23
|
# File 'lib/facebooker/batch_request.rb', line 21
def exception_raised?
@exception.nil? ? false : raise(@exception)
end
|
#respond_to?(name) ⇒ Boolean
25
26
27
|
# File 'lib/facebooker/batch_request.rb', line 25
def respond_to?(name)
super || @result.respond_to?(name)
end
|
#result=(result_object) ⇒ Object
13
14
15
|
# File 'lib/facebooker/batch_request.rb', line 13
def result=(result_object)
@result = @proc.nil? ? result_object : @proc.call(result_object)
end
|