Class: Kiosk::WordPress::Category

Inherits:
Resource
  • Object
show all
Defined in:
lib/kiosk/word_press/category.rb

Class Method Summary collapse

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

#expire

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.

Raises:



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