Class: Workarea::ReleaseSession

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/release_session.rb

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ ReleaseSession

Returns a new instance of ReleaseSession.



3
4
5
# File 'app/models/workarea/release_session.rb', line 3

def initialize(session)
  @session = session
end

Instance Method Details

#expired_by_page_views?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'app/models/workarea/release_session.rb', line 20

def expired_by_page_views?
  @session[:release_page_views].present? &&
    @session[:release_page_views].to_i > max_page_views
end

#expired_by_time?Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'app/models/workarea/release_session.rb', line 11

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

#max_page_viewsObject



25
26
27
# File 'app/models/workarea/release_session.rb', line 25

def max_page_views
  Workarea.config.release_session_max_page_views
end

#remind?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/models/workarea/release_session.rb', line 7

def remind?
  expired_by_time? || expired_by_page_views?
end

#reset!Object



40
41
42
43
# File 'app/models/workarea/release_session.rb', line 40

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

#save_page_viewObject



29
30
31
32
# File 'app/models/workarea/release_session.rb', line 29

def save_page_view
  incremented = @session[:release_page_views].to_i + 1
  @session[:release_page_views] = incremented
end

#save_release_changeObject Also known as: touch



34
35
36
37
# File 'app/models/workarea/release_session.rb', line 34

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

#timeoutObject



16
17
18
# File 'app/models/workarea/release_session.rb', line 16

def timeout
  Workarea.config.release_session_timeout.ago
end