Class: Rainforest::Resource
- Inherits:
-
Object
- Object
- Rainforest::Resource
- Defined in:
- lib/rainforest/resource/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#create ⇒ Object
Create resource.
-
#delete ⇒ Object
Delete resource.
-
#initialize(hash = nil) ⇒ Resource
constructor
A new instance of Resource.
-
#retrieve(id = nil) ⇒ Object
Get resource.
- #update ⇒ Object
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
#create ⇒ Object
Create resource
28 29 |
# File 'lib/rainforest/resource/base.rb', line 28 def create end |
#delete ⇒ Object
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 |
#update ⇒ Object
36 37 |
# File 'lib/rainforest/resource/base.rb', line 36 def update end |