Class: Rester::Client::Resource
- Inherits:
-
Object
- Object
- Rester::Client::Resource
- Defined in:
- lib/rester/client/resource.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #delete(params = {}) ⇒ Object
- #get(params = {}) ⇒ Object
-
#initialize(client, path = '') ⇒ Resource
constructor
A new instance of Resource.
- #update(params = {}) ⇒ Object
Constructor Details
#initialize(client, path = '') ⇒ Resource
Returns a new instance of Resource.
7 8 9 10 |
# File 'lib/rester/client/resource.rb', line 7 def initialize(client, path='') @client = client @path = path end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object (private)
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rester/client/resource.rb', line 26 def method_missing(meth, *args, &block) meth = meth.to_s arg = args.first case arg when Hash, NilClass _handle_search_or_create(meth, arg || {}) when String, Symbol Resource.new(client, _path(meth, arg)) else raise ArgumentError, "invalid argument type #{arg.inspect}" end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/rester/client/resource.rb', line 4 def client @client end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/rester/client/resource.rb', line 5 def path @path end |
Instance Method Details
#delete(params = {}) ⇒ Object
20 21 22 |
# File 'lib/rester/client/resource.rb', line 20 def delete(params={}) _request(:delete, '', params) end |
#get(params = {}) ⇒ Object
12 13 14 |
# File 'lib/rester/client/resource.rb', line 12 def get(params={}) _request(:get, '', params) end |
#update(params = {}) ⇒ Object
16 17 18 |
# File 'lib/rester/client/resource.rb', line 16 def update(params={}) _request(:put, '', params) end |