Sha256: a6eb161d18896d5176c658f692da870a9b2e0c289687a6b077b7ebfec74cfdfe
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module HitList::RailsModelExtension def self.redis_connection @redis_connection ||= begin puts "HitList::RailsModelExtension: No Redis connection provided. Creating new with default settings" Redis.new end end def self.redis_connection=(connection) @redis_connection = connection end module ClassMethods def top_records(count = 5) counter = HitList::Counter.new(HitList::RailsModelExtension.redis_connection, self.name) counter.top_records(count) end end module InstanceMethods def hit_list_day_count 7 end def total_hits hit_counter.total_hits(self.id) end def increment_hit_counter! hit_counter.hit!(self.id) end def increment_only_total_hits! hit_counter.increment_total_hits!(self.id) end def increment_only_rank! hit_counter.increment_rank!(self.id) end def hit_counter @hit_counter ||= HitList::Counter.new(HitList::RailsModelExtension.redis_connection, self.class.name, hit_list_day_count) end end def self.included(receiver) receiver.extend ClassMethods receiver.send :include, InstanceMethods end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hit_list-1.1.1 | lib/hit_list/rails_model_extension.rb |