2005-01-24 19:52:04 +01:00
|
|
|
# Contains all the lock methods to be mixed in with the page
|
|
|
|
module PageLock
|
|
|
|
LOCKING_PERIOD = 30 * 60 # 30 minutes
|
|
|
|
|
2005-02-13 19:53:49 +01:00
|
|
|
attr_reader :locked_by
|
|
|
|
|
2005-01-24 19:52:04 +01:00
|
|
|
def lock(time, locked_by)
|
|
|
|
@locked_at, @locked_by = time, locked_by
|
|
|
|
end
|
|
|
|
|
|
|
|
def lock_duration(time)
|
|
|
|
((time - @locked_at) / 60).to_i unless @locked_at.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
def unlock
|
|
|
|
@locked_at = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def locked?(comparison_time)
|
|
|
|
@locked_at + LOCKING_PERIOD > comparison_time unless @locked_at.nil?
|
|
|
|
end
|
|
|
|
|
2005-01-15 21:26:54 +01:00
|
|
|
end
|