Sha256: 728964d69eef0a03ae131eb19d23c361746963fc65808f7c25ba6be95107a4f8

Contents?: true

Size: 630 Bytes

Versions: 5

Compression:

Stored size: 630 Bytes

Contents

module Ruboty
  module Handlers
    class Base
      class << self
        include Mem

        def inherited(child)
          Ruboty.handlers << child
        end

        def on(pattern, options = {})
          actions << Action.new(pattern, options)
        end

        def actions
          []
        end
        memoize :actions
      end

      include Env::Validatable

      attr_reader :robot

      def initialize(robot)
        @robot = robot
        validate!
      end

      def call(message)
        self.class.actions.each do |action|
          action.call(self, message)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruboty-1.0.4 lib/ruboty/handlers/base.rb
ruboty-1.0.3 lib/ruboty/handlers/base.rb
ruboty-1.0.2 lib/ruboty/handlers/base.rb
ruboty-1.0.1 lib/ruboty/handlers/base.rb
ruboty-1.0.0 lib/ruboty/handlers/base.rb