Sha256: ad605651b75a0d6b8b9ed2d9360d40c2ab7770dad37503f94c91b1172f97f231

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

module Impressionizer
  module ImpressionsController
    module ClassMethods
      def impressionize(args={})
      end
    end
    
    module InstanceMethods
      def impressionize
        if %q('show').include? action_name  
          @object = controller_name.singularize.capitalize.constantize.find(params[:id])
          @object.impressions.create(
            :session_hash => request.session_options[:id],
            :request_hash => ActiveSupport::SecureRandom.hex(187),
            :referrer => request.referer,
            :ip_address => request.remote_ip,
            :user_id => current_user_id
          )
        end
      end
      
      private
      
      def current_user_id
        current_user_id = @current_user ? @current_user.id : nil
        current_user_id = current_user ? current_user.id : nil rescue nil
        current_user_id
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
impressionizer-0.0.3 app/controllers/impressionizer/impressions_controller.rb
impressionizer-0.0.2 app/controllers/impressionizer/impressions_controller.rb