module Incline::Extensions::ActionControllerBase::ClassMethods

Adds some class methods to the base action controller.

Public Instance Methods

allow_anon(*args) click to toggle source

Enables anonymous access for actions.

Pass false to disable anonymous access for all actions(default). Pass true to allow anonymous access for all actions. Pass action names to enable anonymous access for specific actions.

With no arguments, the current setting is returned.

allow_anon false
allow_anon true
allow_anon :home, :about
# File lib/incline/extensions/action_controller_base.rb, line 65
def allow_anon(*args)
  if args.blank?
    @allow_anon ||= false
  else
    @allow_anon = setting_value(args)
  end
end
allow_anon_for?(action) click to toggle source

Determines if the current request can be allowed with an anonymous user.

Overridden by require_admin_for_request? Implied by require_anon_for_request?

# File lib/incline/extensions/action_controller_base.rb, line 120
def allow_anon_for?(action)
  require_anon_for?(action) || setting_for_action(allow_anon, action)
end
allow_http_for?(action) click to toggle source

Determines if the current request can be allowed via HTTP (non-SSL).

# File lib/incline/extensions/action_controller_base.rb, line 143
def allow_http_for?(action)
  setting_for_action allow_non_ssl, action
end
allow_non_ssl(*args) click to toggle source

Enables or disables HTTP (non-SSL) for actions.

Pass false to disable HTTP for all actions(default). Pass true to enable HTTP for all actions. Pass action names to enable HTTP for specific actions.

With no arguments, the current setting is returned.

allow_non_ssl false
allow_non_ssl true
allow_non_ssl :home, :about
# File lib/incline/extensions/action_controller_base.rb, line 44
def allow_non_ssl(*args)
  if args.blank?
    @allow_non_ssl ||= false
  else
    @allow_non_ssl = setting_value(args)
  end
end
auto_api?() click to toggle source

Determines if the controller is configured for auto API.

# File lib/incline/extensions/action_controller_base.rb, line 27
def auto_api?
  @enable_auto_api ||= false
end
disable_auto_api() click to toggle source

Turn off auto API for the controller.

# File lib/incline/extensions/action_controller_base.rb, line 21
def disable_auto_api
  @enable_auto_api = false
end
enable_auto_api() click to toggle source

Turn on auto API for the controller.

# File lib/incline/extensions/action_controller_base.rb, line 15
def enable_auto_api
  @enable_auto_api = true
end
require_admin(*args) click to toggle source

Enables requiring a system administrator for actions.

Pass false to allow non-system administrators access for all actions(default). Pass true to require system administrators for all actions. Pass action names to require system administrators for specific actions.

With no arguments, the current setting is returned.

require_admin false
require_admin true
require_admin :new, :edit, :create, :update, :destroy
# File lib/incline/extensions/action_controller_base.rb, line 86
def require_admin(*args)
  if args.blank?
    @require_admin ||= false
  else
    @require_admin = setting_value(args)
  end
end
require_admin_for?(action) click to toggle source

Determines if the current request requires a system administrator.

Overrides all other access requirements.

# File lib/incline/extensions/action_controller_base.rb, line 128
def require_admin_for?(action)
  setting_for_action require_admin, action
end
require_anon(*args) click to toggle source

Enables requiring an anonymous user for actions.

Pass false to allow logged in users access for all actions(default). Pass true to require anonymous users for all actions. Pass action names to require anonymous for specific actions.

With no arguments, the current setting is returned.

require_anon false
require_anon true
require_anon :new, :edit, :create, :update, :destroy
# File lib/incline/extensions/action_controller_base.rb, line 107
def require_anon(*args)
  if args.blank?
    @require_anon ||= false
  else
    @require_anon = setting_value(args)
  end
end
require_anon_for?(action) click to toggle source

Determines if the current request requires an anonymous user.

Overridden by require_admin_for_request? Implies allow_anon_for_request?

# File lib/incline/extensions/action_controller_base.rb, line 137
def require_anon_for?(action)
  setting_for_action require_anon, action
end

Private Instance Methods

setting_for_action(setting, action) click to toggle source
# File lib/incline/extensions/action_controller_base.rb, line 160
def setting_for_action(setting, action)
  return false unless setting
  if setting.is_a?(::Array)
    return false unless setting.include?(action.to_sym)
  end
  true
end
setting_value(args) click to toggle source
# File lib/incline/extensions/action_controller_base.rb, line 150
def setting_value(args)
  if args.include?(false)
    false
  elsif args.include?(true)
    true
  else
    args.map{|v| v.is_a?(::Symbol) ? v : v.to_s.to_sym }
  end
end