Class: Eventbrite::APIResource
Instance Attribute Summary
#token
Class Method Summary
collapse
Instance Method Summary
collapse
#[], #[]=, #as_json, construct_from, #each, #initialize, #inspect, #keys, #next?, #next_page, #paginated?, #refresh_from, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Eventbrite::EventbriteObject
Class Method Details
.class_name ⇒ Object
3
4
5
6
|
# File 'lib/eventbrite/api_resource.rb', line 3
def self.class_name
name_without_namespace = self.name.split('::')[-1]
name_without_namespace.gsub(/([^\^])([A-Z])/,'\1_\2').downcase
end
|
.retrieve(id, token = nil) ⇒ Object
28
29
30
31
32
|
# File 'lib/eventbrite/api_resource.rb', line 28
def self.retrieve(id, token=nil)
instance = self.new(id, token)
instance.refresh
instance
end
|
.url ⇒ Object
8
9
10
11
12
13
|
# File 'lib/eventbrite/api_resource.rb', line 8
def self.url
if self == APIResource
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Event, Attendee, etc.)')
end
"/#{CGI.escape(class_name.downcase)}s"
end
|
Instance Method Details
#refresh ⇒ Object
22
23
24
25
26
|
# File 'lib/eventbrite/api_resource.rb', line 22
def refresh
response, token = Eventbrite.request(:get, url, @token, @retrieve_options)
refresh_from(response, token)
self
end
|
#url ⇒ Object
15
16
17
18
19
20
|
# File 'lib/eventbrite/api_resource.rb', line 15
def url
unless id = self.id
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}")
end
"#{self.class.url}/#{CGI.escape(id)}"
end
|