Sha256: 2adf51e6d2006a6c218f4d8b805cf61dbeaad83e3d187812dc38990ad4d614db
Contents?: true
Size: 812 Bytes
Versions: 1
Compression:
Stored size: 812 Bytes
Contents
module Impressionizer module Impressionable def is_impressionable has_many :impressions, :as => :impressionable, :class_name => "Impressionizer::Impression" extend ClassMethods include InstanceMethods end module ClassMethods def most_impressions self.scoped.select{|obj| obj.impression_count > 0}.sort_by{|obj| -obj.impression_count} end def most_unique_impressions self.scoped.select{|obj| obj.impression_count > 0}.sort_by{|obj| -obj.unique_impression_count} end end module InstanceMethods def impressionable? true end def impression_count impressions.size end def unique_impression_count impressions.group(:ip_address).size.size end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
impressionizer-0.0.3 | app/models/impressionizer/impressionable.rb |