lib/redis-model-extension.rb in redis-model-extension-0.2.2 vs lib/redis-model-extension.rb in redis-model-extension-0.2.3
- old
+ new
@@ -250,18 +250,20 @@
end
#remove all aliases
def destroy_aliases!
self.class.conf[:redis_aliases].each do |alias_name, fields|
- Database.redis.del(self.class.generate_alias_key(alias_name, self.args)) if self.class.alias_exists?(alias_name, self.args)
+ if self.class.valid_alias_key?(alias_name, self.args) && self.class.alias_exists?(alias_name, self.args)
+ Database.redis.del(self.class.generate_alias_key(alias_name, self.args))
+ end
end
end
#Method for creating aliases
def create_aliases
main_key = redis_key
self.class.conf[:redis_aliases].each do |alias_name, fields|
- Database.redis.set(self.class.generate_alias_key(alias_name, self.args), main_key)
+ Database.redis.set(self.class.generate_alias_key(alias_name, self.args), main_key) if self.class.valid_alias_key?(alias_name, self.args)
end
end
#get redis key for instance
def redis_key
\ No newline at end of file