Sha256: 7d9d7a6fdeed7c35fd3ee1d97a233d0cd5be9af1b278f5b4c54c07241fe83df6

Contents?: true

Size: 538 Bytes

Versions: 12

Compression:

Stored size: 538 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

12 entries across 12 versions & 1 rubygems

Version Path
mangopay-3.0.25 lib/mangopay/resource.rb
mangopay-3.0.23 lib/mangopay/resource.rb
mangopay-3.0.21 lib/mangopay/resource.rb
mangopay-3.0.20 lib/mangopay/resource.rb
mangopay-3.0.19 lib/mangopay/resource.rb
mangopay-3.0.18 lib/mangopay/resource.rb
mangopay-3.0.17 lib/mangopay/resource.rb
mangopay-3.0.16 lib/mangopay/resource.rb
mangopay-3.0.15 lib/mangopay/resource.rb
mangopay-3.0.14 lib/mangopay/resource.rb
mangopay-3.0.13 lib/mangopay/resource.rb
mangopay-3.0.12 lib/mangopay/resource.rb