Module: Simplecast::Client::Resource

Includes:
Simplecast::Configurable
Included in:
Episode, Podcast, Statistic
Defined in:
lib/simplecast/client/resource.rb

Instance Attribute Summary

Attributes included from Simplecast::Configurable

#api_key, #podcast_id

Instance Method Summary collapse

Methods included from Simplecast::Configurable

#configure, keys, #options

Instance Method Details

#allObject



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

#clientObject



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

#modelObject



19
20
21
# File 'lib/simplecast/client/resource.rb', line 19

def model
  Simplecast.const_get(name.split("::").last)
end

#resource_plural_name_lowerObject



13
14
15
# File 'lib/simplecast/client/resource.rb', line 13

def resource_plural_name_lower
  send(:name).split('::').last.downcase + "s"
end