Class: Cloopen::REST::ListResource
- Inherits:
-
Object
- Object
- Cloopen::REST::ListResource
- Includes:
- Utils
- Defined in:
- lib/cloopen/rest/list_resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#instance_key ⇒ Object
readonly
Returns the value of attribute instance_key.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #create(params = {}) ⇒ Object
-
#initialize(uri, client) ⇒ ListResource
constructor
A new instance of ListResource.
- #inspect ⇒ Object
Methods included from Utils
#beautify_hash, #build_body, #cloopfy, #decloopfy, #downcase_first, #prase_body
Constructor Details
#initialize(uri, client) ⇒ ListResource
Returns a new instance of ListResource.
8 9 10 11 12 13 14 |
# File 'lib/cloopen/rest/list_resource.rb', line 8 def initialize(uri, client) @uri, @client = uri, client @instance_key ||= self.class.name.split('::')[-1] resource_name = self.class.name.split('::')[-1] @instance_class = Cloopen::REST.const_get resource_name.chop end |
Instance Attribute Details
#instance_key ⇒ Object (readonly)
Returns the value of attribute instance_key.
6 7 8 |
# File 'lib/cloopen/rest/list_resource.rb', line 6 def instance_key @instance_key end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/cloopen/rest/list_resource.rb', line 6 def uri @uri end |
Instance Method Details
#create(params = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/cloopen/rest/list_resource.rb', line 20 def create(params={}) raise "Can't create a resource without a REST Client" unless @client response = @client.post self, params @instance_class.new @uri, @client, response end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/cloopen/rest/list_resource.rb', line 16 def inspect "<#{self.class} @uri='#{@uri}'>" end |