class DelayedImpressionist def self.before_filter(*args) return end include ImpressionistController::InstanceMethods @queue = :low def initialize(request,controller_name,action_name,user,obj) @controller_name = controller_name @action_name = action_name @user = User.find user unless user.nil? @request = request end def self.perform(*args) arg = args[0] @request= DelayImpressionistRequest.new @request.restore(arg["request"]) request = @request obj = eval("#{arg["class"]}.find '#{arg['obj']['_id']}'") # imp = new(@request,arg["controller_name"],arg["action_name"],arg["user"],obj) new_impression = obj.impressions.build(:user_id=>arg["user"],:controller_name=>arg["controller_name"],:action_name=>arg["action_name"],:ip_address=>@request.remote_ip,:referrer=>@request.referer) new_impression.save obj.update_attribute(:view_count,obj.impression_count) end private def user @user end def action_name @action_name end def controller_name @controller_name end def request @request end end