Module: Repim::Application

Defined in:
lib/repim/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/repim/application.rb', line 5

def self.included(base)
  base.cattr_accessor :user_klass
  base.cattr_accessor :login_template
  base.cattr_accessor :with_single_access
  base.user_klass = (User rescue nil) # assign nil when LoadError and/or ConstMissing
  base. = "sessions/new"
  base.with_single_access = (base.user_klass.column_names.include?('single_access_token') rescue false)

  base.before_filter :authenticate
  [:current_user, :signed_in?, :logged_in?].each do |method|
    base.helper_method method
    base.hide_action method
  end
end

Instance Method Details

#current_userObject



23
24
25
26
27
28
# File 'lib/repim/application.rb', line 23

def current_user
  return nil if @__current_user__ == false
  return @__current_user__ if @__current_user__
  @__current_user__ ||= (user_from_session || false)
  current_user # call again
end

#signed_in?Boolean Also known as: logged_in?

Returns:

  • (Boolean)


20
# File 'lib/repim/application.rb', line 20

def signed_in?; !!current_user ; end