Sha256: e149f7f017d0a5d7f1c2b9cb4b7666d39b9b8ed9211846055ea977a62304220a

Contents?: true

Size: 914 Bytes

Versions: 78

Compression:

Stored size: 914 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
    autoload :Jar, "jets/controller/cookies/jar"

    def cookies
      @cookies ||= Jar.new(self)
    end
  end
end

Version data entries

78 entries across 78 versions & 2 rubygems

Version Path
jets-1.8.2 lib/jets/controller/cookies.rb
jets-1.8.1 lib/jets/controller/cookies.rb
jets-1.8.0 lib/jets/controller/cookies.rb
jets-1.7.2 lib/jets/controller/cookies.rb
jets-1.7.1 lib/jets/controller/cookies.rb
jets-1.7.0 lib/jets/controller/cookies.rb
jets-fs-1.6.10 lib/jets/controller/cookies.rb
jets-1.6.9 lib/jets/controller/cookies.rb
jets-1.6.8 lib/jets/controller/cookies.rb
jets-1.6.7 lib/jets/controller/cookies.rb
jets-1.6.6 lib/jets/controller/cookies.rb
jets-1.6.5 lib/jets/controller/cookies.rb
jets-1.6.4 lib/jets/controller/cookies.rb
jets-1.6.3 lib/jets/controller/cookies.rb
jets-1.6.2 lib/jets/controller/cookies.rb
jets-1.6.1 lib/jets/controller/cookies.rb
jets-1.6.0 lib/jets/controller/cookies.rb
jets-1.5.10 lib/jets/controller/cookies.rb
jets-1.5.9 lib/jets/controller/cookies.rb
jets-1.5.8 lib/jets/controller/cookies.rb