Module: PageLock
- Included in:
- Page
- Defined in:
- app/models/page_lock.rb
Overview
Contains all the lock methods to be mixed in with the page
Constant Summary collapse
- LOCKING_PERIOD =
30 minutes
30 * 60
Instance Attribute Summary collapse
-
#locked_by ⇒ Object
readonly
Returns the value of attribute locked_by.
Instance Method Summary collapse
- #lock(time, locked_by) ⇒ Object
- #lock_duration(time) ⇒ Object
- #locked?(comparison_time) ⇒ Boolean
- #unlock ⇒ Object
Instance Attribute Details
#locked_by ⇒ Object (readonly)
Returns the value of attribute locked_by.
5 6 7 |
# File 'app/models/page_lock.rb', line 5 def locked_by @locked_by end |
Instance Method Details
#lock(time, locked_by) ⇒ Object
7 8 9 |
# File 'app/models/page_lock.rb', line 7 def lock(time, locked_by) @locked_at, @locked_by = time, locked_by end |
#lock_duration(time) ⇒ Object
11 12 13 |
# File 'app/models/page_lock.rb', line 11 def lock_duration(time) ((time - @locked_at) / 60).to_i unless @locked_at.nil? end |
#locked?(comparison_time) ⇒ Boolean
19 20 21 |
# File 'app/models/page_lock.rb', line 19 def locked?(comparison_time) @locked_at + LOCKING_PERIOD > comparison_time unless @locked_at.nil? end |
#unlock ⇒ Object
15 16 17 |
# File 'app/models/page_lock.rb', line 15 def unlock @locked_at = nil end |