Class: Waylon::Route

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/waylon/route.rb

Overview

A Route is a way of connecting a Sense to the right Skill, allowing for things like permissions, prioritization, and scopes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, destination:, condition:, priority: 10) ⇒ Route

Returns a new instance of Route.

Parameters:

  • name (String)

    The name of this route (for use in logging and exceptions)

  • destination (Class)

    The Skill subclass to send matching requests to

  • condition (Condition)

    The Condition used to see if this Route matches a request

  • priority (Integer) (defaults to: 10)

    The priority value (for resolving conflicts). Highest value wins.



15
16
17
18
19
20
21
22
23
24
# File 'lib/waylon/route.rb', line 15

def initialize(name:, destination:, condition:, priority: 10)
  validate_name(name)
  validate_destination(destination)
  validate_condition(condition)
  validate_priority(priority)
  @name = name
  @destination = destination
  @condition = condition
  @priority = priority
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



9
10
11
# File 'lib/waylon/route.rb', line 9

def condition
  @condition
end

#destinationObject (readonly)

Returns the value of attribute destination.



9
10
11
# File 'lib/waylon/route.rb', line 9

def destination
  @destination
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/waylon/route.rb', line 9

def name
  @name
end

#priorityObject (readonly)

Returns the value of attribute priority.



9
10
11
# File 'lib/waylon/route.rb', line 9

def priority
  @priority
end