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
- (BatchRequest) initialize(params, proc)
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
- (Object) method_missing(name, *args, &proc)
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
- (Object) method
Returns the value of attribute method
5
6
7
|
# File 'lib/facebooker/batch_request.rb', line 5
def method
@method
end
|
- (Object) uri
Returns the value of attribute uri
4
5
6
|
# File 'lib/facebooker/batch_request.rb', line 4
def uri
@uri
end
|
Instance Method Details
- (Object) ===(other)
31
32
33
|
# File 'lib/facebooker/batch_request.rb', line 31
def ===(other)
other === @result
end
|
- (Object) exception_raised=(ex)
19
20
21
|
# File 'lib/facebooker/batch_request.rb', line 19
def exception_raised=(ex)
@exception=ex
end
|
- (Boolean) exception_raised?
23
24
25
|
# File 'lib/facebooker/batch_request.rb', line 23
def exception_raised?
@exception.nil? ? false : raise(@exception)
end
|
- (Boolean) respond_to?(name)
27
28
29
|
# File 'lib/facebooker/batch_request.rb', line 27
def respond_to?(name)
super || @result.respond_to?(name)
end
|
- (Object) result=(result_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
|