Sha256: 7805651d1026aecbb7116cec1c1087e4fd66d7ffd624b47fa941516745264e51

Contents?: true

Size: 864 Bytes

Versions: 113

Compression:

Stored size: 864 Bytes

Contents

# Based on sinatra/cookies.rb
# https://github.com/sinatra/sinatra/blob/master/sinatra-contrib/lib/sinatra/cookies.rb
class Jets::Controller
  # = Jets::Controller::Cookies
  #
  # Easy way to deal with cookies
  #
  # == Usage
  #
  # Allows you to read cookies:
  #
  #   def index
  #     "value: #{cookies[:something]}"
  #   end
  #
  # And of course to write cookies:
  #
  #   def show
  #     cookies[:something] = 'foobar'
  #     render json: cookies
  #   end
  #
  # And generally behaves like a hash:
  #
  #   def index
  #     cookies.merge! 'foo' => 'bar', 'bar' => 'baz'
  #     cookies.keep_if { |key, value| key.start_with? 'b' }
  #     foo, bar = cookies.values_at 'foo', 'bar'
  #     puts "size: #{cookies.length}"
  #     render json: cookies
  #   end
  #
  module Cookies
    def cookies
      @cookies ||= Jar.new(self)
    end
  end
end

Version data entries

113 entries across 113 versions & 3 rubygems

Version Path
jets-4.0.12 lib/jets/controller/cookies.rb
jets-4.0.11 lib/jets/controller/cookies.rb
jets-4.0.10 lib/jets/controller/cookies.rb
jets-4.0.9 lib/jets/controller/cookies.rb
jets-4.0.8 lib/jets/controller/cookies.rb
jets-4.0.7 lib/jets/controller/cookies.rb
jets-4.0.6 lib/jets/controller/cookies.rb
jets-4.0.5 lib/jets/controller/cookies.rb
jets-4.0.4 lib/jets/controller/cookies.rb
jets-4.0.3 lib/jets/controller/cookies.rb
jets-4.0.2 lib/jets/controller/cookies.rb
jets-4.0.1 lib/jets/controller/cookies.rb
jets-4.0.0 lib/jets/controller/cookies.rb
jets-3.2.2 lib/jets/controller/cookies.rb
jets-3.2.1 lib/jets/controller/cookies.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/controller/cookies.rb
jets-3.2.0 lib/jets/controller/cookies.rb
jets-3.1.5 lib/jets/controller/cookies.rb
jets-3.1.4 lib/jets/controller/cookies.rb
jets-3.1.3 lib/jets/controller/cookies.rb