Skip to content

Instantly share code, notes, and snippets.

@eLafo
Created July 17, 2013 10:47
Show Gist options
  • Save eLafo/6019528 to your computer and use it in GitHub Desktop.
Save eLafo/6019528 to your computer and use it in GitHub Desktop.
module SamyRoad
module Redis
module Objects
extend ActiveSupport::Concern
included do
include ::Redis::Objects
end
module ClassMethods
def has_counter(name, options = {})
counter_name = name.to_s + "_counter"
method_name = name.to_s + "_count"
counter(counter_name, options)
define_method method_name do
send(counter_name).value
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment