Module: Lotus::Action::Cookies

Defined in:
lib/lotus/action/cookies.rb

Overview

Cookies API

This module isn’t included by default.

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#cookiesLotus::Action::CookieJar (protected)

Gets the cookies from the request and expose them as an Hash

Examples:

require 'lotus/controller'
require 'lotus/action/cookies'

class Show
  include Lotus::Action
  include Lotus::Action::Cookies

  def call(params)
    # ...

    # get a value
    cookies[:user_id] # => '23'

    # set a value
    cookies[:foo] = 'bar'

    # remove a value
    cookies[:bax] = nil
  end
end

Returns:

Since:

  • 0.1.0



55
56
57
# File 'lib/lotus/action/cookies.rb', line 55

def cookies
  @cookies ||= CookieJar.new(@_env.dup, headers)
end

#finishObject (protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Finalize the response by flushing cookies into the response

See Also:

Since:

  • 0.1.0



22
23
24
25
# File 'lib/lotus/action/cookies.rb', line 22

def finish
  super
  cookies.finish
end