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 Method Summary collapse

Instance Method Details

#lock(time, locked_by) ⇒ Object



5
6
7
# File 'app/models/page_lock.rb', line 5

def lock(time, locked_by)
  @locked_at, @locked_by = time, locked_by
end

#lock_duration(time) ⇒ Object



9
10
11
# File 'app/models/page_lock.rb', line 9

def lock_duration(time)
  ((time - @locked_at) / 60).to_i unless @locked_at.nil?
end

#locked?(comparison_time) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/page_lock.rb', line 17

def locked?(comparison_time)
  @locked_at + LOCKING_PERIOD > comparison_time unless @locked_at.nil?
end


21
22
23
# File 'app/models/page_lock.rb', line 21

def locked_by_link
  web.make_link(@locked_by)
end

#unlockObject



13
14
15
# File 'app/models/page_lock.rb', line 13

def unlock
  @locked_at = nil
end