module ActiveResource::Singleton

Public Instance Methods

destroy() click to toggle source

Deletes the resource from the remote service.

Examples

weather = Weather.find
weather.destroy
Weather.find # 404 (Resource Not Found)
# File lib/active_resource/singleton.rb, line 84
def destroy
  connection.delete(singleton_path, self.class.headers)
end

Protected Instance Methods

create() click to toggle source

Create (i.e. save to the remote service) the new resource.

# File lib/active_resource/singleton.rb, line 99
def create
  connection.post(singleton_path, encode, self.class.headers).tap do |response|
    self.id = id_from_response(response)
    load_attributes_from_response(response)
  end
end
update() click to toggle source

Update the resource on the remote service

# File lib/active_resource/singleton.rb, line 92
def update
  connection.put(singleton_path(prefix_options), encode, self.class.headers).tap do |response|
    load_attributes_from_response(response)
  end
end

Private Instance Methods

singleton_path(options = nil) click to toggle source
# File lib/active_resource/singleton.rb, line 108
def singleton_path(options = nil)
  self.class.singleton_path(options || prefix_options)
end