Skip to content

Instantly share code, notes, and snippets.

@flooose
Created April 19, 2012 08:37
Show Gist options
  • Select an option

  • Save flooose/2419708 to your computer and use it in GitHub Desktop.

Select an option

Save flooose/2419708 to your computer and use it in GitHub Desktop.
Module with dynamic method.
module RedisSupport
after_save :load_into_redis
before_destroy :remove_from_redis
def self.included(base)
unless base.respond_to? :load_into_redis
raise(Exception.new, "Please define the methods \"load_into_redis\" before including this module")
end
end
# This method needs to be customize for each model
def load_into_redis
end
def remove_from_redis
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment