Class: Redd::Models::WikiPage

Inherits:
LazyModel show all
Defined in:
lib/redd/models/wiki_page.rb

Overview

A reddit user.

Instance Attribute Summary

Attributes inherited from BasicModel

#client

Instance Method Summary collapse

Methods inherited from LazyModel

#force_load, #initialize, #method_missing, #respond_to_missing?, #to_h

Methods inherited from BasicModel

from_id, #initialize, #inspect, #method_missing, #respond_to_missing?, #to_ary, #to_h

Constructor Details

This class inherits a constructor from Redd::Models::LazyModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Redd::Models::LazyModel

Instance Method Details

#edit(content, reason: nil) ⇒ Object

Edit the wiki page.

Parameters:

  • content (String)

    the new wiki page contents

  • reason (String, nil) (defaults to: nil)

    an optional reason for editing the page


12
13
14
15
16
# 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