Class: Line::Bot::Event::Base
- Inherits:
-
Object
- Object
- Line::Bot::Event::Base
- Defined in:
- lib/pleiades/core_ext/line/bot/event/base.rb
Instance Method Summary collapse
-
#initialize(src) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(src) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pleiades/core_ext/line/bot/event/base.rb', line 10 def initialize(src) @src = Pleiades::Util.define_reader src # moduleにする # /^[a-z]+_event\?$/ # => トークタイプの判定メソッドに反応する。 # # @src.source.type => 'user' # user_event? => true # room_event? => false # hoge_event? => false # @src.define_singleton_method(:method_missing) do |method, *_| return super() unless /^[a-z]+_event\?$/ =~ method source.type == method.to_s.split('_').first end @src.deep_freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_) ⇒ Object (private)
32 33 34 35 |
# File 'lib/pleiades/core_ext/line/bot/event/base.rb', line 32 def method_missing(method, *_) @src.respond_to?(method) || super @src.__send__ method end |