class Object

Public Class Methods

authenticates(model = nil, options = {}, &hook) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 7
def authenticates(model = nil, options = {}, &hook)
  authentication = authentication_class_for model, options

  define_method authentication_hook_name_for(:success, nil, class_name: authentication) do
    instance_eval &hook unless authentication.current.exists?
  end
end
authenticates!(model = nil, options = {}) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 23
def authenticates!(model = nil, options = {})
  before_action authentication_hook_name_for(:success, model, options), options.except(:class_name)
end
authentication_class_for(model, options) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 39
def authentication_class_for(model, options)
  (options[:class_name].presence || "#{model.to_s.classify}::Authentication").to_s.constantize
end
authentication_hook_name_for(type, model, options) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 43
def authentication_hook_name_for(type, model, options)
  authentication = authentication_class_for model, options
  "#{authentication.to_s.underscore.gsub '/', '_'}_#{type}_hook".to_sym
end
doesnt_authenticate!(model = nil, options = {}) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 27
def doesnt_authenticate!(model = nil, options = {})
  skip_before_action authentication_hook_name_for(:success, model, options), options.except(:class_name)
end
doesnt_unauthenticate!(model = nil, options = {}) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 35
def doesnt_unauthenticate!(model = nil, options = {})
  bskip_efore_action authentication_hook_name_for(:fail, model, options), options.except(:class_name)
end
unauthenticates(model = nil, options = {}, &hook) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 15
def unauthenticates(model = nil, options = {}, &hook)
  authentication = authentication_class_for model, options

  define_method authentication_hook_name_for(:fail, nil, class_name: authentication) do
    instance_eval &hook if authentication.current.exists?
  end
end
unauthenticates!(model = nil, options = {}) click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 31
def unauthenticates!(model = nil, options = {})
  before_action authentication_hook_name_for(:fail, model, options), options.except(:class_name)
end

Public Instance Methods

initialize_authentication() click to toggle source
# File lib/authentication/core_ext/action_controller.rb, line 51
def initialize_authentication
  Authentication::Base.store = session
end