Class: Pageflow::EditLock
Defined Under Namespace
Classes: Error, HeldByOtherSessionError, HeldByOtherUserError, NotHeldError, Null
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Method Details
#acquire(current_user, options = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'app/models/pageflow/edit_lock.rb', line 45
def acquire(current_user, options = {})
verify!(current_user, options)
rescue Error
if options[:force] || timed_out?
entry.create_edit_lock(:user => current_user)
else
raise
end
end
|
#held_by?(user) ⇒ Boolean
33
34
35
|
# File 'app/models/pageflow/edit_lock.rb', line 33
def held_by?(user)
self.user == user
end
|
#matches?(id) ⇒ Boolean
37
38
39
|
# File 'app/models/pageflow/edit_lock.rb', line 37
def matches?(id)
self.id == id.to_i
end
|
#release(current_user) ⇒ Object
55
56
57
58
59
|
# File 'app/models/pageflow/edit_lock.rb', line 55
def release(current_user)
if user == current_user
destroy
end
end
|
#timed_out? ⇒ Boolean
41
42
43
|
# File 'app/models/pageflow/edit_lock.rb', line 41
def timed_out?
Time.now > updated_at + EditLock.time_to_live
end
|
#verify!(current_user, options) ⇒ Object