Class: Flexirest::LazyLoader
- Inherits:
-
Object
- Object
- Flexirest::LazyLoader
show all
- Defined in:
- lib/flexirest/lazy_loader.rb
Instance Method Summary
collapse
Constructor Details
#initialize(request, params = nil) ⇒ LazyLoader
3
4
5
6
7
|
# File 'lib/flexirest/lazy_loader.rb', line 3
def initialize(request, params = nil)
@request = request
@params = params
@result = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/flexirest/lazy_loader.rb', line 9
def method_missing(name, *args)
if @result.nil?
@result = @request.call(@params)
end
@result.send(name, *args)
end
|
Instance Method Details
#respond_to?(name) ⇒ Boolean
16
17
18
19
20
21
|
# File 'lib/flexirest/lazy_loader.rb', line 16
def respond_to?(name)
if @result.nil?
@result = @request.call(@params)
end
@result.respond_to?(name)
end
|