lib/locker/resource.rb in lita-locker-1.0.8 vs lib/locker/resource.rb in lita-locker-1.0.9
- old
+ new
@@ -13,28 +13,28 @@
lock :coord, expiration: 5
attr_reader :id
def initialize(key)
- fail 'Unknown resource key' unless Resource.exists?(key)
+ raise 'Unknown resource key' unless Resource.exists?(key)
@id = key
end
def self.exists?(key)
redis.sismember('resource-list', key)
end
def self.create(key)
- fail 'Resource key already exists' if Resource.exists?(key)
+ raise 'Resource key already exists' if Resource.exists?(key)
redis.sadd('resource-list', key)
r = Resource.new(key)
r.state = 'unlocked'
r.owner_id = ''
r
end
def self.delete(key)
- fail 'Unknown resource key' unless Resource.exists?(key)
+ raise 'Unknown resource key' unless Resource.exists?(key)
%w(state, owner_id).each do |item|
redis.del("resource:#{key}:#{item}")
end
redis.srem('resource-list', key)
end