Class Babylon::Route
In: lib/babylon/router.rb
Parent: Object

Route class which associate an XPATH match and a priority to a controller and an action

Methods

accepts?   new  

Attributes

action  [RW] 
controller  [RW] 
priority  [RW] 
xpath  [RW] 

Public Class methods

Creates a new route

[Source]

    # File lib/babylon/router.rb, line 83
83:     def initialize(params)
84:       raise("No controller given for route") unless params["controller"]
85:       raise("No action given for route") unless params["action"]
86:       raise("No xpath given for route") unless params["xpath"]
87:       @priority   = params["priority"] || 0
88:       @xpath      = params["xpath"] 
89:       @controller = Kernel.const_get("#{params["controller"].capitalize}Controller")
90:       @action     = params["action"]
91:     end

Public Instance methods

Checks that the route matches the stanzas and calls the the action on the controller.

[Source]

    # File lib/babylon/router.rb, line 95
95:     def accepts?(stanza)
96:       stanza.xpath(@xpath, XpathHelper.new).empty? ? false : self
97:     end

[Validate]