Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustmodify/2c608103ff57421c5047c5e72f575213 to your computer and use it in GitHub Desktop.
Save mustmodify/2c608103ff57421c5047c5e72f575213 to your computer and use it in GitHub Desktop.
+ methods(false).each do |name|
+ cleaned_name = name.to_s.gsub("?", "_predicate")
+ hook = <<-eos
+ class << self
+ def #{cleaned_name}_hook *args
+ begin
+ #{cleaned_name}_without_hook(*args)
+ rescue Redis::BaseError => err
+ Rails.logger.debug(err.message)
+ end
+ end
+
+ alias #{cleaned_name}_without_hook #{name}
+ alias #{name} #{cleaned_name}_hook
+ end
+ eos
+ module_eval(hook)
+ end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment