Sha256: 9a13e7ac61111cdc7b54720bdd5ad8bc8f3ed53c74b5b1c30aecff81014201eb

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

module MangoPay
  # @abstract
  class Resource
    class << self
      def class_name
        name.split('::')[-1]
      end

      def 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mangopay-3.0.11 lib/mangopay/resource.rb
mangopay-3.0.10 lib/mangopay/resource.rb