Sha256: 8c4a5e800844dd9ba7408b11997bb34b267e30237a2294804da2f39376152548

Contents?: true

Size: 1022 Bytes

Versions: 3

Compression:

Stored size: 1022 Bytes

Contents

module Netzke
  module ControllerExtensions
    def self.included(base)
      base.send(:before_filter, :set_session_data)
      base.send(:before_filter, :set_controller)
    end
    
    def set_session_data
      ::Netzke::Core.session = session
      session[:netzke_user_id] = defined?(current_user) ? current_user.try(:id) : nil
      # set netzke_just_logged_in and netzke_just_logged_out states (may be used by Netzke components)
      if session[:_netzke_next_request_is_first_after_login]
        session[:netzke_just_logged_in] = true
        session[:_netzke_next_request_is_first_after_login] = false
      else
        session[:netzke_just_logged_in] = false
      end

      if session[:_netzke_next_request_is_first_after_logout]
        session[:netzke_just_logged_out] = true
        session[:_netzke_next_request_is_first_after_logout] = false
      else
        session[:netzke_just_logged_out] = false
      end
    end

    def set_controller
       ::Netzke::Core.controller = self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netzke-core-0.6.2 lib/netzke/rails/controller_extensions.rb
netzke-core-0.6.1 lib/netzke/rails/controller_extensions.rb
netzke-core-0.6.0 lib/netzke/rails/controller_extensions.rb