Class: Rainforest::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/rainforest/resource/base.rb

Direct Known Subclasses

Runs

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Resource

Returns a new instance of Resource.



6
7
8
9
10
11
12
13
14
# File 'lib/rainforest/resource/base.rb', line 6

def initialize(hash=nil)
  if hash.class == Hash 
    hash.each do |k,v|
      self.instance_variable_set("@#{k}", v)
    end
  end  
  @api_client = Rainforest::Client.new

end

Instance Method Details

#createObject

Create resource



28
29
# File 'lib/rainforest/resource/base.rb', line 28

def create
end

#deleteObject

Delete resource



32
33
# File 'lib/rainforest/resource/base.rb', line 32

def delete
end

#retrieve(id = nil) ⇒ Object

Get resource



17
18
19
20
21
22
23
24
25
# File 'lib/rainforest/resource/base.rb', line 17

def retrieve(id=nil)
  if id.is_a? Integer
    object = self.class.name.split('::')[-1].downcase + '/' + id.to_s
    @api_client.request(object, nil, :get)
  else 
    object = self.class.name.split('::')[-1].downcase + '/' + id.to_s
    @api_client.request(object, nil, :get)
  end
end

#updateObject



36
37
# File 'lib/rainforest/resource/base.rb', line 36

def update
end