Sha256: ba917daf54dc81ea98d7d1bad4fb5df833ff301517d739e0e107af54910d86a1

Contents?: true

Size: 681 Bytes

Versions: 17

Compression:

Stored size: 681 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, options = {})
        self.class.actions.inject(false) do |matched, action|
          matched | action.call(self, message, options)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ruboty-1.3.1 lib/ruboty/handlers/base.rb
ruboty-1.3.0 lib/ruboty/handlers/base.rb
ruboty-1.2.4 lib/ruboty/handlers/base.rb
ruboty-1.2.3 lib/ruboty/handlers/base.rb
ruboty-1.2.2 lib/ruboty/handlers/base.rb
ruboty-1.2.1 lib/ruboty/handlers/base.rb
ruboty-1.2.0 lib/ruboty/handlers/base.rb
ruboty-1.1.9 lib/ruboty/handlers/base.rb
ruboty-1.1.8 lib/ruboty/handlers/base.rb
ruboty-1.1.7 lib/ruboty/handlers/base.rb
ruboty-1.1.6 lib/ruboty/handlers/base.rb
ruboty-1.1.5 lib/ruboty/handlers/base.rb
ruboty-1.1.4 lib/ruboty/handlers/base.rb
ruboty-1.1.3 lib/ruboty/handlers/base.rb
ruboty-1.1.2 lib/ruboty/handlers/base.rb
ruboty-1.1.1 lib/ruboty/handlers/base.rb
ruboty-1.1.0 lib/ruboty/handlers/base.rb