Sha256: 1e2a74422c21148452bd8f4cbdfffa9668bd28484f7f07a84b456ab5a7386c19

Contents?: true

Size: 503 Bytes

Versions: 6

Compression:

Stored size: 503 Bytes

Contents

module Rainforest
  class SingletonAPIResource < APIResource
    def self.url()
      if self == SingletonAPIResource
        raise NotImplementedError.new('SingletonAPIResource is an abstract class.  You should perform actions on its subclasses (Account, etc.)')
      end
      "/v1/#{CGI.escape(class_name.downcase)}"
    end

    def url
      self.class.url
    end

    def self.retrieve(api_key=nil)
      instance = self.new(nil, api_key)
      instance.refresh
      instance
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rainforest-1.0.7 lib/rainforest/singleton_api_resource.rb
rainforest-1.0.6 lib/rainforest/singleton_api_resource.rb
rainforest-1.0.5 lib/rainforest/singleton_api_resource.rb
rainforest-1.0.4 lib/rainforest/singleton_api_resource.rb
rainforest-1.0.3 lib/rainforest/singleton_api_resource.rb
rainforest-1.0.1 lib/rainforest/singleton_api_resource.rb