Sha256: a8e69665cb980e9ab8a485100260275ee56820596695fe905eb82256ceaca872
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
require "ostruct" require "delegate" module PodcastIndex class Category < SimpleDelegator class << self def find(id) category = all.detect { |element| element.id == id } raise PodcastIndex::CategoryNotFound if category.nil? category end def all response = Api::Categories.list from_response_collection(response) end private def from_response_collection(response, collection_key = "feeds") response[collection_key].map do |item| category = item.transform_keys(&:underscore) new(JSON.parse(category.to_json, object_class: OpenStruct)) # rubocop:disable Style/OpenStructUse end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
podcast_index-0.5.0 | lib/podcast_index/category.rb |
podcast_index-0.4.0 | lib/podcast_index/category.rb |