Class: Liberty::Router::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/liberty/router/node.rb

Constant Summary collapse

MUSTERMANN_VERSION =
"5.0"
DYNAMIC_PREFIX =
/:/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



11
12
13
14
15
# File 'lib/liberty/router/node.rb', line 11

def initialize
  @endpoint = nil
  @static = nil
  @dynamic = nil
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



9
10
11
# File 'lib/liberty/router/node.rb', line 9

def endpoint
  @endpoint
end

Instance Method Details

#add(segment) ⇒ Object



17
18
19
# File 'lib/liberty/router/node.rb', line 17

def add(segment)
  dynamic?(segment) ? add_dynamic(segment) : add_static(segment)
end

#attach(endpoint) ⇒ Object



25
26
27
# File 'lib/liberty/router/node.rb', line 25

def attach(endpoint)
  @endpoint = endpoint
end

#find(segment) ⇒ Object



21
22
23
# File 'lib/liberty/router/node.rb', line 21

def find(segment)
  find_node(segment) { |params| yield(symbolize_keys(params)) if params && block_given? }
end


29
30
31
32
# File 'lib/liberty/router/node.rb', line 29

def print(verb, routes, prefix = "")
  print_segments(@static, routes, verb, prefix)
  print_segments(@dynamic, routes, verb, prefix)
end