Class: MC2P::CRUDResource

Inherits:
CRResource show all
Defined in:
lib/base.rb

Overview

Resource that allows send requests of delete, change, create, list and detail

Instance Method Summary collapse

Methods inherited from CRResource

#create

Methods inherited from ReadOnlyResource

#list

Methods inherited from DetailOnlyResource

#detail

Methods inherited from ResourceMixin

#_one_item, #detail_url

Constructor Details

#initialize(api_request, path, object_item_class) ⇒ CRUDResource

Initializes a resource Params:

api_request

Api request used to make all the requests to the API

path

Path used to make all the requests to the API

object_item_class

Object item class used to return values



307
308
309
310
311
312
313
314
315
# File 'lib/base.rb', line 307

def initialize(api_request, path, object_item_class)
  super(api_request, path, object_item_class)
  @change_resource_mixin = ChangeResourceMixin.new(api_request, path,
                                                   object_item_class,
                                                   @paginator_class)
  @delete_resource_mixin = DeleteResourceMixin.new(api_request, path,
                                                   object_item_class,
                                                   @paginator_class)
end

Instance Method Details

#change(resource_id, data) ⇒ Object

Params:

resource_id

id to request

data

data used on the request

Returns: an object item class with the response of the server



321
322
323
# File 'lib/base.rb', line 321

def change(resource_id, data)
  @change_resource_mixin.change(resource_id, data)
end

#delete(resource_id) ⇒ Object

Params: resource_id::id to request



327
328
329
# File 'lib/base.rb', line 327

def delete(resource_id)
  @delete_resource_mixin.delete(resource_id)
end