class Wst::Contents

Public Class Methods

new() click to toggle source
# File lib/wst/contents.rb, line 7
def initialize
  refresh
end

Public Instance Methods

all(show_non_published = false) click to toggle source

Get all contents @param [Boolean] show_non_published Get all contents or only published @return [Array<Content>] Contents

# File lib/wst/contents.rb, line 20
def all(show_non_published = false)
  get @all, show_non_published
end
pages(show_non_published = false) click to toggle source

Get all pages @param [Boolean] show_non_published Get all pages or only published @return [Array<Content>] Contents

# File lib/wst/contents.rb, line 27
def pages(show_non_published = false)
  get @pages, show_non_published
end
posts(show_non_published = false) click to toggle source

Get all posts @param [Boolean] show_non_published Get all posts or only published @return [Array<Content>] Contents

# File lib/wst/contents.rb, line 34
def posts(show_non_published = false)
  get @posts, show_non_published
end
refresh() click to toggle source
# File lib/wst/contents.rb, line 11
def refresh
  @posts = Post.all
  @pages = Page.all
  @all = [@posts, @pages].flatten
end

Private Instance Methods

get(contents, show_non_published) click to toggle source
# File lib/wst/contents.rb, line 39
def get(contents, show_non_published)
  return contents if show_non_published
  contents.select { |c| c.published }
end