Sha256: ada71874d79e8bbd5ae504cb55e02fcd1036f3832387ceefca59fa39788a317f

Contents?: true

Size: 555 Bytes

Versions: 8

Compression:

Stored size: 555 Bytes

Contents

module MangoPay
  # @abstract
  class Resource

    protected

    def self.class_name
      self.name.split('::')[-1]
    end

    def self.url(id = nil)
      if self == Resource
        raise NotImplementedError.new('Resource is an abstract class. Do not use it directly.')
      end
      if id
        "/v2/#{MangoPay.configuration.client_id}/#{CGI.escape(class_name.downcase)}s/#{CGI.escape(id.to_s)}"
      else
        "/v2/#{MangoPay.configuration.client_id}/#{CGI.escape(class_name.downcase)}s"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mangopay-3.0.9 lib/mangopay/resource.rb
mangopay-3.0.8 lib/mangopay/resource.rb
mangopay-3.0.7 lib/mangopay/resource.rb
mangopay-3.0.6 lib/mangopay/resource.rb
mangopay-3.0.5 lib/mangopay/resource.rb
mangopay-3.0.4 lib/mangopay/resource.rb
mangopay-3.0.3 lib/mangopay/resource.rb
mangopay-3.0.2 lib/mangopay/resource.rb