Sha256: e65ed5d6017243217e46b688435e6bd75e42f5225b510dca0767403642fd10b1
Contents?: true
Size: 809 Bytes
Versions: 2
Compression:
Stored size: 809 Bytes
Contents
# Abstract class to be inherited from handler class. # # Example: # # class MyHandler < Ellen::Handlers::Base # on /kill\z/ do |message| # say "Good bye, cruel world..." # exit # end # end # module Ellen module Handlers class Base class << self include Mem def inherited(child) Ellen.handlers << child end def on(pattern, options = {}, &block) actions << Action.new(pattern, options, &block) end def actions [] end memoize :actions end attr_reader :robot def initialize(robot) @robot = robot end def call(message) self.class.actions.each do |action| action.call(self, message) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ellen-0.0.7 | lib/ellen/handlers/base.rb |
ellen-0.0.6 | lib/ellen/handlers/base.rb |