namespace impressionable model module class methods with 'impressionist_'

This commit is contained in:
Ross Kaffenberger committed 2012-03-19 14:31:05 -04:00
1 parent 594889a3db
commit 380f49cf62
5 files changed
+14 -14

No files matched your search

+9 -9
View File
@@ -3,19 +3,19 @@ module Impressionist
extend ActiveSupport::Concern
module ClassMethods
attr_accessor :cache_options
@cache_options = nil
attr_accessor :impressionist_cache_options
@impressionist_cache_options = nil
def counter_cache_options
if @cache_options
def impressionist_counter_cache_options
if @impressionist_cache_options
options = { :column_name => :impressions_count, :unique => false }
options.merge!(@cache_options) if @cache_options.is_a?(Hash)
options.merge!(@impressionist_cache_options) if @impressionist_cache_options.is_a?(Hash)
options
end
end
def counter_caching?
counter_cache_options.present?
def impressionist_counter_caching?
impressionist_counter_cache_options.present?
end
end
@@ -33,7 +33,7 @@ module Impressionist
end
def update_counter_cache
cache_options = self.class.counter_cache_options
cache_options = self.class.impressionist_counter_cache_options
column_name = cache_options[:column_name].to_sym
count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count
update_attribute(column_name, count)
@@ -56,4 +56,4 @@ module Impressionist
impressionist_count({:start_date=>start_date, :end_date=>end_date, :filter=> :session_hash})
end
end
end
end