Module: Simplecast::Client::Resource
Instance Attribute Summary
#api_key, #podcast_id
Instance Method Summary
collapse
#configure, keys, #options
Instance Method Details
#all ⇒ Object
9
10
11
12
|
# File 'lib/simplecast/client/resource.rb', line 9
def all
all = client.get("#{resource_plural_name_lower}.json")
all.map {|item| model.new(item) }
end
|
#client ⇒ Object
16
17
18
|
# File 'lib/simplecast/client/resource.rb', line 16
def client
@client ||= Simplecast.client
end
|
#find(id) ⇒ Object
5
6
7
8
|
# File 'lib/simplecast/client/resource.rb', line 5
def find(id)
api_obj = client.get("#{resource_plural_name_lower}/#{id}.json")
model.new(api_obj)
end
|
#model ⇒ Object
19
20
21
|
# File 'lib/simplecast/client/resource.rb', line 19
def model
Simplecast.const_get(name.split("::").last)
end
|
#resource_plural_name_lower ⇒ Object
13
14
15
|
# File 'lib/simplecast/client/resource.rb', line 13
def resource_plural_name_lower
send(:name).split('::').last.downcase + "s"
end
|