Sha256: 3065ec5cfb65f3213018f5105bb5ca57ba46c20e915fc243da0ce46a2e1c2390

Contents?: true

Size: 517 Bytes

Versions: 47

Compression:

Stored size: 517 Bytes

Contents

module MangoPay
  # @abstract
  class Resource
    class << self
      def class_name
        name.split('::').last
      end

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

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
mangopay-3.28.0 lib/mangopay/resource.rb
mangopay-3.27.0 lib/mangopay/resource.rb
mangopay-3.26.1 lib/mangopay/resource.rb
mangopay-3.26.0 lib/mangopay/resource.rb
mangopay-3.25.1 lib/mangopay/resource.rb
mangopay-3.25.0 lib/mangopay/resource.rb
mangopay-3.24.1 lib/mangopay/resource.rb
mangopay-3.24.0 lib/mangopay/resource.rb
mangopay-3.23.0 lib/mangopay/resource.rb
mangopay-3.22.0 lib/mangopay/resource.rb
mangopay-3.21.0 lib/mangopay/resource.rb
mangopay-3.20.0 lib/mangopay/resource.rb
mangopay-3.19.0 lib/mangopay/resource.rb
mangopay-3.18.0 lib/mangopay/resource.rb
mangopay-3.17.0 lib/mangopay/resource.rb
mangopay-3.16.0 lib/mangopay/resource.rb
mangopay-3.15.0 lib/mangopay/resource.rb
mangopay-3.14.0 lib/mangopay/resource.rb
mangopay-3.13.2 lib/mangopay/resource.rb
mangopay-3.12.0 lib/mangopay/resource.rb