Module: Incline::Extensions::ActionControllerBase::ClassMethods
- Defined in:
- lib/incline/extensions/action_controller_base.rb
Overview
Adds some class methods to the base action controller.
Instance Method Summary collapse
-
#allow_anon(*args) ⇒ Object
Enables anonymous access for actions.
-
#allow_anon_for?(action) ⇒ Boolean
Determines if the current request can be allowed with an anonymous user.
-
#allow_http_for?(action) ⇒ Boolean
Determines if the current request can be allowed via HTTP (non-SSL).
-
#allow_non_ssl(*args) ⇒ Object
Enables or disables HTTP (non-SSL) for actions.
-
#auto_api? ⇒ Boolean
Determines if the controller is configured for auto API.
-
#disable_auto_api ⇒ Object
Turn off auto API for the controller.
-
#enable_auto_api ⇒ Object
Turn on auto API for the controller.
-
#require_admin(*args) ⇒ Object
Enables requiring a system administrator for actions.
-
#require_admin_for?(action) ⇒ Boolean
Determines if the current request requires a system administrator.
-
#require_anon(*args) ⇒ Object
Enables requiring an anonymous user for actions.
-
#require_anon_for?(action) ⇒ Boolean
Determines if the current request requires an anonymous user.
Instance Method Details
#allow_anon(*args) ⇒ Object
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
65 66 67 68 69 70 71 |
# 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) ⇒ Boolean
Determines if the current request can be allowed with an anonymous user.
Overridden by require_admin_for_request? Implied by require_anon_for_request?
120 121 122 |
# 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) ⇒ Boolean
Determines if the current request can be allowed via HTTP (non-SSL).
143 144 145 |
# 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) ⇒ Object
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
44 45 46 47 48 49 50 |
# 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? ⇒ Boolean
Determines if the controller is configured for auto API.
27 28 29 |
# File 'lib/incline/extensions/action_controller_base.rb', line 27 def auto_api? @enable_auto_api ||= false end |
#disable_auto_api ⇒ Object
Turn off auto API for the controller.
21 22 23 |
# File 'lib/incline/extensions/action_controller_base.rb', line 21 def disable_auto_api @enable_auto_api = false end |
#enable_auto_api ⇒ Object
Turn on auto API for the controller.
15 16 17 |
# File 'lib/incline/extensions/action_controller_base.rb', line 15 def enable_auto_api @enable_auto_api = true end |
#require_admin(*args) ⇒ Object
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
86 87 88 89 90 91 92 |
# 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) ⇒ Boolean
Determines if the current request requires a system administrator.
Overrides all other access requirements.
128 129 130 |
# 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) ⇒ Object
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
107 108 109 110 111 112 113 |
# 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) ⇒ Boolean
Determines if the current request requires an anonymous user.
Overridden by require_admin_for_request? Implies allow_anon_for_request?
137 138 139 |
# File 'lib/incline/extensions/action_controller_base.rb', line 137 def require_anon_for?(action) setting_for_action require_anon, action end |