Class: Layer::ResourceProxy
- Inherits:
-
Object
- Object
- Layer::ResourceProxy
show all
- Defined in:
- lib/layer/resource_proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(client, base, resource) ⇒ ResourceProxy
Returns a new instance of ResourceProxy.
3
4
5
6
7
|
# File 'lib/layer/resource_proxy.rb', line 3
def initialize(client, base, resource)
@client = client
@base = base
@resource = resource
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
13
14
15
|
# File 'lib/layer/resource_proxy.rb', line 13
def method_missing(method, *args, &block)
@resource.public_send(method, *([@client, url] + args), &block)
end
|
Instance Method Details
#respond_to_missing?(method, include_private = false) ⇒ Boolean
17
18
19
|
# File 'lib/layer/resource_proxy.rb', line 17
def respond_to_missing?(method, include_private = false)
@resource.respond_to?(method) || super
end
|
#url ⇒ Object
9
10
11
|
# File 'lib/layer/resource_proxy.rb', line 9
def url
@base.nil? ? @resource.url : "#{@base.url}/#{@resource.url}"
end
|