Sha256: 7c0a9229d1199ebc6584ee5cda08f9f6ecbb8b39c8e08bb7d4f9880aee512a50

Contents?: true

Size: 1.02 KB

Versions: 28

Compression:

Stored size: 1.02 KB

Contents

module Workarea
  class ReleaseSession
    def initialize(session)
      @session = session
    end

    def remind?
      expired_by_time? || expired_by_page_views?
    end

    def expired_by_time?
      @session[:release_changed_at].present? &&
        Time.zone.parse(@session[:release_changed_at]) < timeout
    end

    def timeout
      Workarea.config.release_session_timeout.ago
    end

    def expired_by_page_views?
      @session[:release_page_views].present? &&
        @session[: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 = @session[:release_page_views].to_i + 1
      @session[:release_page_views] = incremented
    end

    def save_release_change
      reset!
      @session[:release_changed_at] = Time.current.to_s
    end
    alias_method :touch, :save_release_change

    def reset!
      @session.delete(:release_page_views)
      @session.delete(:release_changed_at)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/release_session.rb
workarea-core-3.5.26 app/models/workarea/release_session.rb
workarea-core-3.5.25 app/models/workarea/release_session.rb
workarea-core-3.5.23 app/models/workarea/release_session.rb
workarea-core-3.5.22 app/models/workarea/release_session.rb
workarea-core-3.5.21 app/models/workarea/release_session.rb
workarea-core-3.5.20 app/models/workarea/release_session.rb
workarea-core-3.5.19 app/models/workarea/release_session.rb
workarea-core-3.5.18 app/models/workarea/release_session.rb
workarea-core-3.5.17 app/models/workarea/release_session.rb
workarea-core-3.5.16 app/models/workarea/release_session.rb
workarea-core-3.5.15 app/models/workarea/release_session.rb
workarea-core-3.5.14 app/models/workarea/release_session.rb
workarea-core-3.5.13 app/models/workarea/release_session.rb
workarea-core-3.5.12 app/models/workarea/release_session.rb
workarea-core-3.5.11 app/models/workarea/release_session.rb
workarea-core-3.5.10 app/models/workarea/release_session.rb
workarea-core-3.5.9 app/models/workarea/release_session.rb
workarea-core-3.5.8 app/models/workarea/release_session.rb
workarea-core-3.5.7 app/models/workarea/release_session.rb