Sha256: a5bf1d23666d6bdd3d55ce8a8eddd59dc543d342cc4226af004f5d265c3aee7e

Contents?: true

Size: 508 Bytes

Versions: 6

Compression:

Stored size: 508 Bytes

Contents

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

  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

  def locked_by_link
    web.make_link(@locked_by)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
Pimki-1.4.092 app/models/page_lock.rb
Pimki-1.5.092 app/models/page_lock.rb
Pimki-1.7.092 app/models/page_lock.rb
Pimki-1.8.092 app/models/page_lock.rb
Pimki-1.6.092 app/models/page_lock.rb
Pimki-1.8.200 app/models/page_lock.rb