Class: Wee::ComponentDispatcher

Inherits:
Component show all
Defined in:
lib/wee/components/component_dispatcher.rb

Instance Method Summary collapse

Methods inherited from Component

#add_decoration, #backtrack_state_chain, #decoration, #decoration=, #do_render_chain, #each_decoration, #process_callbacks_chain, #remove_decoration, #remove_decoration_if, #render

Methods inherited from Presenter

#get_property, #lookup_property, #properties, #properties=, #render, #session, template, uses_property

Constructor Details

#initializeComponentDispatcher

Returns a new instance of ComponentDispatcher.



4
5
6
7
8
# File 'lib/wee/components/component_dispatcher.rb', line 4

def initialize
  super()
  @rules = []
  @components = Set.new
end

Instance Method Details

#add_rule(pattern, component, &block) ⇒ Object



10
11
12
13
# File 'lib/wee/components/component_dispatcher.rb', line 10

def add_rule(pattern, component, &block)
  @components.add(component)
  @rules << [pattern, component, block]
end

#backtrack_state(snapshot) ⇒ Object



27
28
29
30
31
32
# File 'lib/wee/components/component_dispatcher.rb', line 27

def backtrack_state(snapshot)
  snapshot.add(@__decoration)
  @components.each do |component|
    component.backtrack_state_chain(snapshot)
  end
end

#do_render(rendering_context) ⇒ Object



15
16
17
18
19
# File 'lib/wee/components/component_dispatcher.rb', line 15

def do_render(rendering_context)
  if component = match(session.current_context.request.info)
    component.do_render_chain(rendering_context)
  end
end

#process_callbacks(&block) ⇒ Object



21
22
23
24
25
# File 'lib/wee/components/component_dispatcher.rb', line 21

def process_callbacks(&block)
  if component = match(session.current_context.request.info)
    component.process_callbacks_chain(&block)
  end
end