Module: Janus::InternalHelpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- ConfirmationsController, PasswordsController, RegistrationsController, SessionsController
- Defined in:
- lib/janus/controllers/internal_helpers.rb
Overview
A collection of abstraction helper methods used in Janus controllers and views. This should be of no particular outside of abstract controllers for Janus that must be working for all scopes at once.
Instance Method Summary collapse
-
#authenticate! ⇒ Object
Abstract method for the authenticate_scope! before filter, with scope as detected by janus_scope.
-
#janus_scope ⇒ Object
Detects the scope from the controller name.
-
#mailer_class ⇒ Object
Returns the ‘UserMailer` class (or `AdminMailer` or whatever) as detected by janus_scope.
-
#resource ⇒ Object
Returns the ‘@user` instance variable (or `@admin` or whatever), as detected by janus_scope.
-
#resource=(value) ⇒ Object
Sets the ‘@user` instance variable (or `@admin` or whatever), as detected by janus_scope.
-
#resource_class ⇒ Object
Returns the ‘User` class (or `Admin` or whatever) as detected by janus_scope.
-
#resource_name ⇒ Object
Alias for janus_scope.
Instance Method Details
#authenticate! ⇒ Object
Abstract method for the authenticate_scope! before filter, with scope as detected by janus_scope.
14 15 16 |
# File 'lib/janus/controllers/internal_helpers.rb', line 14 def authenticate! send("authenticate_#{janus_scope}!") end |
#janus_scope ⇒ Object
Detects the scope from the controller name.
19 20 21 |
# File 'lib/janus/controllers/internal_helpers.rb', line 19 def janus_scope @janus_scope ||= self.class.name.split('::', 2).first.underscore.singularize end |
#mailer_class ⇒ Object
Returns the ‘UserMailer` class (or `AdminMailer` or whatever) as detected by janus_scope.
48 49 50 |
# File 'lib/janus/controllers/internal_helpers.rb', line 48 def mailer_class @mailer_class ||= (janus_scope.camelize + 'Mailer').constantize end |
#resource ⇒ Object
Returns the ‘@user` instance variable (or `@admin` or whatever), as detected by janus_scope.
25 26 27 |
# File 'lib/janus/controllers/internal_helpers.rb', line 25 def resource instance_variable_get(:"@#{janus_scope}") end |
#resource=(value) ⇒ Object
Sets the ‘@user` instance variable (or `@admin` or whatever), as detected by janus_scope.
31 32 33 |
# File 'lib/janus/controllers/internal_helpers.rb', line 31 def resource=(value) instance_variable_set(:"@#{janus_scope}", value) end |
#resource_class ⇒ Object
Returns the ‘User` class (or `Admin` or whatever) as detected by janus_scope.
37 38 39 |
# File 'lib/janus/controllers/internal_helpers.rb', line 37 def resource_class @resource_class ||= janus_scope.camelize.constantize end |
#resource_name ⇒ Object
Alias for janus_scope.
42 43 44 |
# File 'lib/janus/controllers/internal_helpers.rb', line 42 def resource_name janus_scope end |