Sha256: 60d5d8e91273d5ef4336cb6369a62c0555c132772b8d48bb31361316f9cd3657
Contents?: true
Size: 1.1 KB
Versions: 34
Compression:
Stored size: 1.1 KB
Contents
module Workarea class ReleaseSession def initialize(cookies) @cookies = cookies end def remind? expired_by_time? || expired_by_page_views? end def expired_by_time? @cookies.permanent[:release_changed_at].present? && Time.zone.parse(@cookies.permanent[:release_changed_at]) < timeout end def timeout Workarea.config.release_session_timeout.ago end def expired_by_page_views? @cookies.permanent[:release_page_views].present? && @cookies.permanent[:release_page_views].to_i > max_page_views end def max_page_views Workarea.config.release_session_max_page_views end def save_page_view incremented = @cookies.permanent[:release_page_views].to_i + 1 @cookies.permanent[:release_page_views] = incremented end def save_release_change reset! @cookies.permanent[:release_changed_at] = Time.current.to_s end alias_method :touch, :save_release_change def reset! @cookies.permanent[:release_page_views] = nil @cookies.permanent[:release_changed_at] = nil end end end
Version data entries
34 entries across 34 versions & 1 rubygems