Class: Poundpay::Resource

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/poundpay/resource.rb

Direct Known Subclasses

ChargePermission, Developer, Payment, User

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.primary_keyObject



12
13
14
# File 'lib/poundpay/resource.rb', line 12

def primary_key
  @primary_key ||= 'sid'
end

Class Method Details

.collection_path(prefix_options = {}, query_options = nil) ⇒ Object

Modified default to not use an extension



29
30
31
32
# File 'lib/poundpay/resource.rb', line 29

def collection_path(prefix_options = {}, query_options = nil)
  path = super(prefix_options, query_options)
  remove_extension(path)
end

.custom_method_collection_url(method_name, options = {}) ⇒ Object

Modified default to not use an extension



35
36
37
38
# File 'lib/poundpay/resource.rb', line 35

def custom_method_collection_url(method_name, options = {})
  path = super(method_name, options)
  remove_extension(path)
end

.element_path(id, prefix_options = {}, query_options = nil) ⇒ Object

Modified default to not use an extension



17
18
19
20
# File 'lib/poundpay/resource.rb', line 17

def element_path(id, prefix_options = {}, query_options = nil)
  path = super(id, prefix_options, query_options)
  remove_extension(path)
end

.instantiate_collection(collection, prefix_options = {}) ⇒ Object

Handle paginated collections



41
42
43
44
45
# File 'lib/poundpay/resource.rb', line 41

def instantiate_collection(collection, prefix_options = {})
  # TODO: Consume pages
  collection = collection[collection_name]
  super(collection, prefix_options)
end

.new_element_path(prefix_options = {}) ⇒ Object

Modified default to not use an extension



23
24
25
26
# File 'lib/poundpay/resource.rb', line 23

def new_element_path(prefix_options = {})
  path = super(prefix_options)
  remove_extension(path)
end

Instance Method Details

#collection_nameObject



59
60
61
# File 'lib/poundpay/resource.rb', line 59

def collection_name
  self.class.collection_name
end

#encodeObject

Poundpay accepts urlencoded form parameters Ideally we should override this functionality in the format, but it’s not very straightforward to do so



55
56
57
# File 'lib/poundpay/resource.rb', line 55

def encode
  Resource.urlencode(@attributes)
end