Class: Plum::Rack::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/plum/rack/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app:, plum:, sock:, logger:, server_push: true, remote_addr: "127.0.0.1") ⇒ Session

Returns a new instance of Session.


11
12
13
14
15
16
17
18
19
20
# File 'lib/plum/rack/session.rb', line 11

def initialize(app:, plum:, sock:, logger:, server_push: true, remote_addr: "127.0.0.1")
  @app = app
  @plum = plum
  @sock = sock
  @logger = logger
  @server_push = server_push
  @remote_addr = remote_addr

  setup_plum
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app


9
10
11
# File 'lib/plum/rack/session.rb', line 9

def app
  @app
end

#plumObject (readonly)

Returns the value of attribute plum


9
10
11
# File 'lib/plum/rack/session.rb', line 9

def plum
  @plum
end

Instance Method Details

#runObject


26
27
28
29
30
31
32
33
34
35
# File 'lib/plum/rack/session.rb', line 26

def run
  begin
    while !@sock.closed? && !@sock.eof?
      @plum << @sock.readpartial(16384)
    end
  rescue Errno::EPIPE, Errno::ECONNRESET => e
  rescue StandardError => e
    @logger.error("#{e.class}: #{e.message}\n#{e.backtrace.map { |b| "\t#{b}" }.join("\n")}")
  end
end

#stopObject


22
23
24
# File 'lib/plum/rack/session.rb', line 22

def stop
  @plum.close
end