Module: Pleiades::Command::Routing::RouteRefine

Included in:
NestBlocks, Pleiades::Command::RoutingProxy
Defined in:
lib/pleiades/core/command/routing/route_refine.rb

Instance Method Summary collapse

Instance Method Details

#only_events(*events, &block) ⇒ Object

指定したイベントの時のみブロックを実行する

## EXAMPLE only_events :postback do

event scope :hoge, action: :fuga
# => Hoge::Fuga を postbackイベントとして実行する

end



13
14
15
16
17
18
19
# 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) ⇒ Object

指定したトークタイプの時のみブロックを実行する

## EXAMPLE talk_type :user do

p @event.source.type # => "user"
postback scope :hoge, action: :fuga

end



29
30
31
32
33
34
35
# 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