Module: Redd::Models::Messageable

Included in:
Subreddit, User
Defined in:
lib/redd/models/messageable.rb

Overview

A model that can be messaged (i.e. Users and Subreddits).

Instance Method Summary collapse

Instance Method Details

#send_message(to:, subject:, text:, from: nil) ⇒ Object

Compose a message to a person or the moderators of a subreddit.

Parameters:

  • to (String)

    the thing to send the message to (overriden by User and Subreddit)

  • subject (String)

    the subject of the message

  • text (String)

    the message text

  • from (Subreddit, nil) (defaults to: nil)

    the subreddit to send the message on behalf of



13
14
15
16
17
# File 'lib/redd/models/messageable.rb', line 13

def send_message(to:, subject:, text:, from: nil)
  params = { to: to, subject: subject, text: text }
  params[:from_sr] = from.display_name if from
  @client.post('/api/compose', params)
end