Module: Messed::Controller::Respond
- Included in:
- Messed
- Defined in:
- lib/messed/controller/respond.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clear_responses ⇒ Object
- #reply(response, options = {}) ⇒ Object
- #responses ⇒ Object
- #say(response) ⇒ Object
- #set_response(response, options = nil) ⇒ Object
- #whisper(response, options = {}) ⇒ Object
Class Method Details
.included(c) ⇒ Object
5 6 7 8 9 |
# File 'lib/messed/controller/respond.rb', line 5 def self.included(c) c.instance_eval " after_processing :clear_responses " end |
Instance Method Details
#clear_responses ⇒ Object
15 16 17 |
# File 'lib/messed/controller/respond.rb', line 15 def clear_responses responses.clear end |
#reply(response, options = {}) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/messed/controller/respond.rb', line 23 def reply(response, = {}) [:to] ||= .from [:from] ||= .to [:in_reply_to] ||= set_response(response, ) end |
#responses ⇒ Object
11 12 13 |
# File 'lib/messed/controller/respond.rb', line 11 def responses @response ||= [] end |
#say(response) ⇒ Object
19 20 21 |
# File 'lib/messed/controller/respond.rb', line 19 def say(response) set_response(response) end |
#set_response(response, options = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/messed/controller/respond.rb', line 35 def set_response(response, = nil) = .new .body = response.is_a?(Message) ? response.body : response if .each do |key, value| .send(:"#{key}=", value) end end self.responses << end |
#whisper(response, options = {}) ⇒ Object
30 31 32 33 |
# File 'lib/messed/controller/respond.rb', line 30 def whisper(response, = {}) [:private] = true reply(response, ) end |