Class: RouteNode
- Inherits:
-
Object
- Object
- RouteNode
- Defined in:
- lib/rails_notebook/route.rb
Instance Method Summary collapse
- #action ⇒ Object
- #actions ⇒ Object
- #controller ⇒ Object
- #countChildrenNodes(count) ⇒ Object
- #getChildren ⇒ Object
- #getCountChildrenNodes ⇒ Object
- #hasRoute(uri_mapping) ⇒ Object
-
#initialize(_uriPattern, _verb, _controller, _action, _nodeUri) ⇒ RouteNode
constructor
A new instance of RouteNode.
- #insertChild(childNode) ⇒ Object
- #printNode ⇒ Object
- #updateParams(_verb, _controller, _action) ⇒ Object
- #uriPattern ⇒ Object
- #verb ⇒ Object
- #verbs ⇒ Object
Constructor Details
#initialize(_uriPattern, _verb, _controller, _action, _nodeUri) ⇒ RouteNode
Returns a new instance of RouteNode.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/rails_notebook/route.rb', line 3 def initialize( _uriPattern , _verb , _controller , _action, _nodeUri ) @uriPattern = _uriPattern _verb ? @verbs = [_verb] : @verbs = [] @controller = _controller _action ? @actions = [_action] : @actions = [] @countChildrenNodes = 0 @childrenNodes = [] @nodeUri = _nodeUri @id = self.object_id end |
Instance Method Details
#action ⇒ Object
30 31 32 |
# File 'lib/rails_notebook/route.rb', line 30 def action @actions.first end |
#actions ⇒ Object
27 28 29 |
# File 'lib/rails_notebook/route.rb', line 27 def actions @actions end |
#controller ⇒ Object
24 25 26 |
# File 'lib/rails_notebook/route.rb', line 24 def controller @controller end |
#countChildrenNodes(count) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/rails_notebook/route.rb', line 56 def countChildrenNodes( count ) @childrenNodes.each do |child| count = count + child.countChildrenNodes(0) end @countChildrenNodes = count count += 1 return count end |
#getChildren ⇒ Object
36 37 38 |
# File 'lib/rails_notebook/route.rb', line 36 def getChildren @childrenNodes end |
#getCountChildrenNodes ⇒ Object
39 40 41 |
# File 'lib/rails_notebook/route.rb', line 39 def getCountChildrenNodes @countChildrenNodes end |
#hasRoute(uri_mapping) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/rails_notebook/route.rb', line 43 def hasRoute( uri_mapping ) @childrenNodes.each do |childNode| if childNode.uriPattern == uri_mapping return childNode end end return false end |
#insertChild(childNode) ⇒ Object
52 53 54 |
# File 'lib/rails_notebook/route.rb', line 52 def insertChild( childNode ) @childrenNodes << childNode end |
#printNode ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rails_notebook/route.rb', line 65 def printNode puts "====================NODE====================" puts @uriPattern puts @verbs puts @controller puts @actions puts "============================================" @childrenNodes.each do |child| child.printNode end end |
#updateParams(_verb, _controller, _action) ⇒ Object
13 14 15 16 17 |
# File 'lib/rails_notebook/route.rb', line 13 def updateParams( _verb , _controller , _action ) @verbs << _verb unless _verb.nil? @controller = _controller @actions << _action unless _action.nil? end |
#uriPattern ⇒ Object
33 34 35 |
# File 'lib/rails_notebook/route.rb', line 33 def uriPattern @uriPattern end |
#verb ⇒ Object
21 22 23 |
# File 'lib/rails_notebook/route.rb', line 21 def verb @verbs.first end |
#verbs ⇒ Object
18 19 20 |
# File 'lib/rails_notebook/route.rb', line 18 def verbs @verbs end |