Class: Cloopen::REST::ListResource

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/cloopen/rest/list_resource.rb

Direct Known Subclasses

LandingCalls, Messages, SubAccounts

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject (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

#uriObject (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

#inspectObject



16
17
18
# File 'lib/cloopen/rest/list_resource.rb', line 16

def inspect
  "<#{self.class} @uri='#{@uri}'>"
end