Class: Lita::RouteValidator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/route_validator.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Determines if an incoming message should trigger a route.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler, route, message, robot) ⇒ RouteValidator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RouteValidator



21
22
23
24
25
26
# File 'lib/lita/route_validator.rb', line 21

def initialize(handler, route, message, robot)
  @handler = handler
  @route = route
  @message = message
  @robot = robot
end

Instance Attribute Details

#handlerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The handler class the route belongs to.



6
7
8
# File 'lib/lita/route_validator.rb', line 6

def handler
  @handler
end

#messageObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The incoming message.



9
10
11
# File 'lib/lita/route_validator.rb', line 9

def message
  @message
end

#robotObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The currently running robot.



12
13
14
# File 'lib/lita/route_validator.rb', line 12

def robot
  @robot
end

#routeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The route being checked.



15
16
17
# File 'lib/lita/route_validator.rb', line 15

def route
  @route
end

Instance Method Details

#callBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether or not the route should be triggered.



30
31
32
33
34
35
36
37
38
# File 'lib/lita/route_validator.rb', line 30

def call
  return unless command_satisfied?(route, message)
  return if from_self?(message, robot)
  return unless matches_pattern?(route, message)
  return unless authorized?(robot, message.user, route.required_groups)
  return unless passes_route_hooks?(route, message, robot)

  true
end