Sha256: d911620b70006bd50865f91328e72ed4e70caa0912936a964379deb01e264b6f

Contents?: true

Size: 888 Bytes

Versions: 3

Compression:

Stored size: 888 Bytes

Contents

module Sojourn
  module SessionStores
    class Cookie

      def initialize(ctx)
        @ctx = ctx
      end

      def sojourner_uuid
        cookie_data[:uuid]
      end

      def sojourner_uuid=(value)
        cookies.permanent.signed[cookie_name] = { value: cookie_data.merge(uuid: value) }
      end

      def sojourner_tracked?
        cookie_data.key?(:uuid)
      end

      def user_id
        cookie_data[:user_id]
      end

      def user_id=(value)
        cookies.permanent.signed[cookie_name] = { value: cookie_data.merge(user_id: value) }
      end

      def user_tracked?
        cookie_data.key?(:user_id)
      end

    private

      def cookie_data
        cookies.signed[cookie_name] || {}
      end

      def cookies
        @ctx.send(:cookies)
      end

      def cookie_name
        @cookie_name ||= Sojourn.config.cookie_name
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sojourn-1.0.0.pre2 lib/sojourn/session_stores/cookie.rb
sojourn-1.0.0.pre lib/sojourn/session_stores/cookie.rb
sojourn-0.0.7 lib/sojourn/session_stores/cookie.rb