class Redd::Models::WikiPage

A reddit user.

Public Instance Methods

edit(content, reason: nil) click to toggle source

Edit the wiki page. @param content [String] the new wiki page contents @param reason [String, nil] an optional reason for editing the page

# File lib/redd/models/wiki_page.rb, line 12
def edit(content, reason: nil)
  params = { page: @attributes.fetch(:title), content: content }
  params[:reason] = reason if reason
  @client.post("/r/#{@attributes.fetch(:subreddit).display_name}/api/wiki/edit", params)
end

Private Instance Methods

after_initialize() click to toggle source
# File lib/redd/models/wiki_page.rb, line 29
def after_initialize
  return unless @attributes[:revision_by]
  @attributes[:revision_by] = @client.unmarshal(@attributes[:revision_by])
end
default_loader() click to toggle source
# File lib/redd/models/wiki_page.rb, line 20
def default_loader
  title = @attributes.fetch(:title)
  if @attributes.key?(:subreddit)
    sr_name = @attributes[:subreddit].display_name
    return @client.get("/r/#{sr_name}/wiki/#{title}").body[:data]
  end
  @client.get("/wiki/#{title}").body[:data]
end