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.0.30.1 lib/mangopay/resource.rb
mangopay-3.0.30 lib/mangopay/resource.rb
mangopay-3.0.29 lib/mangopay/resource.rb
mangopay-3.0.28 lib/mangopay/resource.rb
mangopay-3.0.27 lib/mangopay/resource.rb
mangopay-3.0.26 lib/mangopay/resource.rb
mangopay-3.0.25.pre.alpha.pre.20 lib/mangopay/resource.rb