Class: HttpRouter::Node::Root

Inherits:
HttpRouter::Node show all
Defined in:
lib/http_router/node/root.rb

Instance Attribute Summary collapse

Attributes inherited from HttpRouter::Node

#router

Instance Method Summary collapse

Methods inherited from HttpRouter::Node

#add_arbitrary, #add_destination, #add_free_match, #add_glob, #add_glob_regexp, #add_lookup, #add_match, #add_request, #add_spanning_match, #add_variable, #inspect, #inspect_matchers_body, #usable?

Constructor Details

#initialize(router) ⇒ Root



6
7
8
9
# File 'lib/http_router/node/root.rb', line 6

def initialize(router)
  super(router, nil)
  @counter, @methods_module = 0, Module.new
end

Instance Attribute Details

#compiledObject (readonly) Also known as: compiled?

Returns the value of attribute compiled.



4
5
6
# File 'lib/http_router/node/root.rb', line 4

def compiled
  @compiled
end

#methods_moduleObject (readonly)

Returns the value of attribute methods_module.



4
5
6
# File 'lib/http_router/node/root.rb', line 4

def methods_module
  @methods_module
end

Instance Method Details

#[](request) ⇒ Object Also known as: compiling_lookup



11
12
13
14
# File 'lib/http_router/node/root.rb', line 11

def [](request)
  compile
  self[request]
end

#depthObject



31
32
33
# File 'lib/http_router/node/root.rb', line 31

def depth
  0
end

#inject_root_ivar(obj) ⇒ Object



25
26
27
28
29
# File 'lib/http_router/node/root.rb', line 25

def inject_root_ivar(obj)
  name = :"@ivar_#{@counter += 1}"
  root.instance_variable_set(name, obj)
  name
end

#inspect_labelObject



35
36
37
# File 'lib/http_router/node/root.rb', line 35

def inspect_label
  "Root (#{@matchers.size} matchers)"
end

#next_counterObject



21
22
23
# File 'lib/http_router/node/root.rb', line 21

def next_counter
  @counter += 1
end

#uncompileObject



17
18
19
# File 'lib/http_router/node/root.rb', line 17

def uncompile
  instance_eval "undef :[]; alias :[] :compiling_lookup", __FILE__, __LINE__ if compiled?
end