Class: MangoPay::Resource Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/mangopay/resource.rb

Overview

This class is abstract.

Class Method Summary collapse

Class Method Details

.class_nameObject



5
6
7
# File 'lib/mangopay/resource.rb', line 5

def class_name
  name.split('::').last
end

.url(id = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/mangopay/resource.rb', line 9

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