Class: RhoGallery::Consumer

Inherits:
Base
  • Object
show all
Defined in:
lib/rhogallery/consumer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#errors, #id, #initialize

Constructor Details

This class inherits a constructor from RhoGallery::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RhoGallery::Base

Class Method Details

.find(id = "", options = RhoGallery.credentials) ⇒ Object



24
25
26
27
# File 'lib/rhogallery/consumer.rb', line 24

def self.find(id = "", options = RhoGallery.credentials)
  consumer = RhoGallery::Base.find(id, options, "consumers")
  RhoGallery::Consumer.new(RhoGallery.prepare_hash(consumer))
end

.find_all(options = RhoGallery.credentials) ⇒ Object



29
30
31
32
# File 'lib/rhogallery/consumer.rb', line 29

def self.find_all(options = RhoGallery.credentials)
  consumers = RhoGallery::Base.find_all(options, "consumers")
  consumers.collect!{|consumer| RhoGallery::Consumer.new(RhoGallery.prepare_hash(consumer))} unless consumers.empty?
end

Instance Method Details

#create(data = @attributes, options = RhoGallery.credentials, resource = "consumers") ⇒ Object



3
4
5
# File 'lib/rhogallery/consumer.rb', line 3

def create(data = @attributes, options = RhoGallery.credentials, resource = "consumers")
  super(data, options, resource)
end

#delete(options = RhoGallery.credentials, resource = "consumers/#{self.id}") ⇒ Object



20
21
22
# File 'lib/rhogallery/consumer.rb', line 20

def delete(options = RhoGallery.credentials, resource = "consumers/#{self.id}")
  super(options, resource)
end

#save(data = @attributes, options = RhoGallery.credentials, resource = "consumers") ⇒ Object



7
8
9
# File 'lib/rhogallery/consumer.rb', line 7

def save(data = @attributes, options = RhoGallery.credentials, resource = "consumers")
  super(data, options, resource)
end

#update(data = @attributes, options = RhoGallery.credentials, resource = "consumers/#{self.id}") ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/rhogallery/consumer.rb', line 11

def update(data = @attributes, options = RhoGallery.credentials, resource = "consumers/#{self.id}")
  if super(data, options, resource)
    @attributes = RhoGallery::Consumer::find(self.id, options).get_attributes
    self
  else
    false
  end
end