Class: Wee::PagelessSession

Inherits:
Session show all
Defined in:
lib/wee/pageless/session.rb

Overview

A session class, which does not have a page-store and as such cannot backtrack.

Instance Attribute Summary collapse

Attributes inherited from Session

#component_runner, #page_store

Attributes inherited from RequestHandler

#application, #expire_after, #id, #max_lifetime, #max_requests

Instance Method Summary collapse

Methods inherited from Session

#initialize, #start_request_response_loop

Methods inherited from AbstractSession

current, #current_context, #get_property, #handle_request, #initialize, #properties, #properties=

Methods inherited from RequestHandler

#alive?, #handle_request, #initialize, #statistics, #teminate

Constructor Details

This class inherits a constructor from Wee::Session

Instance Attribute Details

#callbacksObject Also known as: current_callbacks

Returns the value of attribute callbacks.



10
11
12
# File 'lib/wee/pageless/session.rb', line 10

def callbacks
  @callbacks
end

Instance Method Details

#handle_callback_phaseObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/wee/pageless/session.rb', line 42

def handle_callback_phase
  # Actions/inputs were specified.
  #
  # We process the request and invoke actions/inputs. Then we generate a
  # new page view. 

  callback_stream = Wee::CallbackStream.new(self.callbacks, @context.request.fields) 
  send_response = @component_runner.process_callbacks(callback_stream)

  post_callbacks_hook()

  if send_response
    set_response(@context, send_response)    # @context.response = send_response
  else
    handle_new_page_view(@context)
  end
end

#handle_existing_pageObject



26
27
28
29
30
31
32
33
34
# File 'lib/wee/pageless/session.rb', line 26

def handle_existing_page
  p @context.request.fields if $DEBUG

  if @context.request.render?
    handle_render_phase
  else
    handle_callback_phase
  end
end

#handle_render_phaseObject



36
37
38
39
40
# File 'lib/wee/pageless/session.rb', line 36

def handle_render_phase
  new_callbacks = Wee::CallbackRegistry.new(Wee::SimpleIdGenerator.new)
  respond(@context, new_callbacks)   # render
  self.callbacks = new_callbacks
end

#process_requestObject

The main routine where the request is processed.



22
23
24
# File 'lib/wee/pageless/session.rb', line 22

def process_request
  handle_existing_page
end

#setup(&block) ⇒ Object



13
14
15
16
17
18
# File 'lib/wee/pageless/session.rb', line 13

def setup(&block)
  with_session do
    block.call(self) if block
    raise ArgumentError, "No component runner specified" if @component_runner.nil?
  end
end