Class: Stripe::SingletonAPIResource

Inherits:
APIResource show all
Defined in:
lib/stripe/singleton_api_resource.rb

Constant Summary

Constants inherited from APIResource

APIResource::OBJECT_NAME

Constants inherited from StripeObject

Stripe::StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIResource

class_name, custom_method, object_name, #refresh, #request_stripe_object, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Class Method Details

.resource_urlObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/stripe/singleton_api_resource.rb', line 5

def self.resource_url
  if self == SingletonAPIResource
    raise NotImplementedError,
          "SingletonAPIResource is an abstract class. You should " \
          "perform actions on its subclasses (Balance, etc.)"
  end
  # Namespaces are separated in object names with periods (.) and in URLs
  # with forward slashes (/), so replace the former with the latter.
  "/v1/#{object_name.downcase.tr('.', '/')}"
end

.retrieve(params = {}, opts = {}) ⇒ Object



20
21
22
23
24
# File 'lib/stripe/singleton_api_resource.rb', line 20

def self.retrieve(params = {}, opts = {})
  instance = new(params, Util.normalize_opts(opts))
  instance.refresh
  instance
end

Instance Method Details

#resource_urlObject



16
17
18
# File 'lib/stripe/singleton_api_resource.rb', line 16

def resource_url
  self.class.resource_url
end