class Line::Bot::Event::Postback

Attributes

action[R]
params[R]

Public Class Methods

new(src) click to toggle source
Calls superclass method
# File lib/pleiades/core_ext/line/bot/event/postback.rb, line 7
def initialize(src)
  super
  set_instance_variables
end

Private Instance Methods

set_instance_variables() click to toggle source

dataプロパティからインスタンス変数に設定する。

action 'path/to/command' params '{product_id: 1, order_num: 3}'

# File lib/pleiades/core_ext/line/bot/event/postback.rb, line 18
def set_instance_variables
  data =
    postback.data
            .split('&')
            .map { |s| s.split('=') }
            .each_with_object({}) { |(key, val), hash| hash[key.to_sym] = val }

  @action = data.delete :action
  @params = data
end