Class: Mirror::Api::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/mirror-api/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials, resource_name = Request::TIMELINE, options = {}) ⇒ Resource

Returns a new instance of Resource.



9
10
11
12
13
14
15
# File 'lib/mirror-api/resource.rb', line 9

def initialize(credentials, resource_name=Request::TIMELINE, options={})
  @credentials =  credentials
  @resource_name = resource_name
  self.options = options || {}

  raise "Invalid credentials #{credentials}" unless @credentials
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/mirror-api/resource.rb', line 7

def options
  @options
end

Instance Method Details

#create(params) ⇒ Object Also known as: insert



21
22
23
# File 'lib/mirror-api/resource.rb', line 21

def create(params)
  Request.new(@credentials, make_options(params)).post
end

#delete(id, params = nil) ⇒ Object



39
40
41
# File 'lib/mirror-api/resource.rb', line 39

def delete(id, params=nil)
  Request.new(@credentials, item_options(id, params)).delete
end

#get(id, params = nil) ⇒ Object



26
27
28
# File 'lib/mirror-api/resource.rb', line 26

def get(id, params=nil)
  Request.new(@credentials, item_options(id, params)).get
end

#list(*args) ⇒ Object



17
18
19
# File 'lib/mirror-api/resource.rb', line 17

def list(*args)
  handle_list(args)
end

#patch(id, params) ⇒ Object



35
36
37
# File 'lib/mirror-api/resource.rb', line 35

def patch(id, params)
  Request.new(@credentials, item_options(id, params)).patch
end

#update(id, params) ⇒ Object



30
31
32
33
# File 'lib/mirror-api/resource.rb', line 30

def update(id, params)
  # This may become patch later
  Request.new(@credentials, item_options(id, params)).put
end