Class: Kiosk::WordPress::Category
- Defined in:
- lib/kiosk/word_press/category.rb
Class Method Summary collapse
-
.find_by_slug(slug) ⇒ Object
Retrieves a specific category by its slug.
Methods inherited from Resource
all, collection_path, #content, #content_document, #destroy, element_path, element_path_by_slug, #excerpt, find, find_by_associated, instantiate_collection, instantiate_record, #raw_content, #raw_excerpt, #save, #to_param, with_parameters
Methods included from Cacheable::Resource
Class Method Details
.find_by_slug(slug) ⇒ Object
Retrieves a specific category by its slug. This can’t be done directly through the WordPress JSON API, so all categories are traversed instead.
11 12 13 14 15 |
# File 'lib/kiosk/word_press/category.rb', line 11 def self.find_by_slug(slug) category = all.detect { |category| category.slug == slug } raise ResourceNotFound.new("unknown category `#{slug}'") unless category category end |