Class: Rubotnik::PostbackDispatch

Inherits:
Object
  • Object
show all
Includes:
Commands, Helpers
Defined in:
lib/rubotnik/postback_dispatch.rb

Overview

Routing for postbacks

Constant Summary

Constants included from Helpers

Helpers::GRAPH_URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

call_graph_api, get_user_info, message_contains_location?, next_command, say, send_message, show, stop_thread, text_message?

Constructor Details

#initialize(postback) ⇒ PostbackDispatch

Returns a new instance of PostbackDispatch.



12
13
14
15
16
17
# File 'lib/rubotnik/postback_dispatch.rb', line 12

def initialize(postback)
  @postback = postback
  p @postback.class
  p @postback
  @user = Rubotnik::UserStore.instance.find_or_create_user(@postback.sender['id'])
end

Instance Attribute Details

#postbackObject (readonly)

Returns the value of attribute postback.



10
11
12
# File 'lib/rubotnik/postback_dispatch.rb', line 10

def postback
  @postback
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/rubotnik/postback_dispatch.rb', line 10

def user
  @user
end

Instance Method Details

#route(&block) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/rubotnik/postback_dispatch.rb', line 19

def route(&block)
  @matched = false
  instance_eval(&block)
rescue StandardError => error
  raise unless ENV["DEBUG"] == "true"
  stop_thread
  say "There was an error: #{error}"
end