Class: Workarea::ReleaseSession
- Inherits:
-
Object
- Object
- Workarea::ReleaseSession
- Defined in:
- app/models/workarea/release_session.rb
Instance Method Summary collapse
- #expired_by_page_views? ⇒ Boolean
- #expired_by_time? ⇒ Boolean
-
#initialize(session) ⇒ ReleaseSession
constructor
A new instance of ReleaseSession.
- #max_page_views ⇒ Object
- #remind? ⇒ Boolean
- #reset! ⇒ Object
- #save_page_view ⇒ Object
- #save_release_change ⇒ Object (also: #touch)
- #timeout ⇒ Object
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
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
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_views ⇒ Object
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
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_view ⇒ Object
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_change ⇒ Object 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 |