module Pleiades::Command::Routing::RouteRefine
Public Instance Methods
only_events(*events, &block)
click to toggle source
指定したイベントの時のみブロックを実行する
## EXAMPLE only_events
:postback do
event scope :hoge, action: :fuga # => Hoge::Fuga を postbackイベントとして実行する
end
# File lib/pleiades/core/command/routing/route_refine.rb, line 13 def only_events(*events, &block) return false unless callable_event_type?(events.flatten) return self unless block_given? instance_eval(&block) end
talk_type(*talk_types, &block)
click to toggle source
指定したトークタイプの時のみブロックを実行する
## EXAMPLE talk_type
:user do
p @event.source.type # => "user" postback scope :hoge, action: :fuga
end
# File lib/pleiades/core/command/routing/route_refine.rb, line 29 def talk_type(*talk_types, &block) return false unless callable_talk_type?(talk_types.flatten) return self unless block_given? instance_eval(&block) end
Private Instance Methods
callable_event_type?(types)
click to toggle source
# File lib/pleiades/core/command/routing/route_refine.rb, line 43 def callable_event_type?(types) types.map(&:to_s).include?(__event_name__) end
callable_talk_type?(types)
click to toggle source
# File lib/pleiades/core/command/routing/route_refine.rb, line 39 def callable_talk_type?(types) types.map(&:to_s).include?(@event.source.type) end