Class: Liberty::Router::Node
- Inherits:
-
Object
- Object
- Liberty::Router::Node
- Defined in:
- lib/liberty/router/node.rb
Constant Summary collapse
- MUSTERMANN_VERSION =
"5.0"
- DYNAMIC_PREFIX =
/:/
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #add(segment) ⇒ Object
- #attach(endpoint) ⇒ Object
- #find(segment) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #print(verb, routes, prefix = "") ⇒ Object
Constructor Details
#initialize ⇒ Node
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
#endpoint ⇒ Object (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 |
#print(verb, routes, prefix = "") ⇒ Object
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 |