Sha256: 113af1ae94058d6c0dc09bd41555e68928ce194f720b2aa5345ba6912d982672

Contents?: true

Size: 499 Bytes

Versions: 2

Compression:

Stored size: 499 Bytes

Contents

# Contains all the lock methods to be mixed in with the page
module PageLock
  LOCKING_PERIOD = 30 * 60 # 30 minutes

  attr_reader :locked_by

  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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
instiki-0.10.1 app/models/page_lock.rb
instiki-0.10.2 app/models/page_lock.rb