Class: NinshoController
- Inherits:
-
Object
- Object
- NinshoController
- Defined in:
- app/controllers/ninsho_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#build_resource_from_omniauth ⇒ Object
Build a ninsho resource, from the omniauth hash.
-
#flash_message(key, action) ⇒ Object
Sets the flash message with :key, using I18n.
-
#parent_resource ⇒ Object
Parent resource, commonly user.
-
#resource ⇒ Object
Gets the actual resource stored in the instance variable.
-
#resource=(new_resource) ⇒ Object
Sets the resource creating an instance variable.
-
#resource_class ⇒ Object
Class name for the ninsho model commonly Authentication.
-
#resource_name ⇒ Object
Proxy to ninsho map name.
-
#resource_params ⇒ Object
Omniauth hash for creating the records.
Instance Method Details
#build_resource_from_omniauth ⇒ Object
Build a ninsho resource, from the omniauth hash
48 49 50 |
# File 'app/controllers/ninsho_controller.rb', line 48 def build_resource_from_omniauth self.resource = resource_class.from_omniauth(resource_params) end |
#flash_message(key, action) ⇒ Object
Sets the flash message with :key, using I18n. Example (i18n locale file):
en:
ninsho:
:sessions
signed_in: "Signed in successfully"
11 12 13 14 |
# File 'app/controllers/ninsho_controller.rb', line 11 def (key, action) = I18n.t("ninsho.sessions.#{action}") flash[key] = if .present? end |
#parent_resource ⇒ Object
Parent resource, commonly user
43 44 45 |
# File 'app/controllers/ninsho_controller.rb', line 43 def parent_resource resource_class.reflect_on_all_associations(:belongs_to).first.name.to_s end |
#resource ⇒ Object
Gets the actual resource stored in the instance variable
17 18 19 |
# File 'app/controllers/ninsho_controller.rb', line 17 def resource instance_variable_get(:"@#{resource_name}") end |
#resource=(new_resource) ⇒ Object
Sets the resource creating an instance variable
38 39 40 |
# File 'app/controllers/ninsho_controller.rb', line 38 def resource=(new_resource) instance_variable_set(:"@#{resource_name}", new_resource) end |
#resource_class ⇒ Object
Class name for the ninsho model commonly Authentication
33 34 35 |
# File 'app/controllers/ninsho_controller.rb', line 33 def resource_class Ninsho.resource_class end |
#resource_name ⇒ Object
Proxy to ninsho map name
27 28 29 |
# File 'app/controllers/ninsho_controller.rb', line 27 def resource_name Ninsho.resource_name #authentication end |
#resource_params ⇒ Object
Omniauth hash for creating the records
22 23 24 |
# File 'app/controllers/ninsho_controller.rb', line 22 def resource_params env['omniauth.auth'] end |