Class: Anoubis::ApplicationController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Anoubis::ApplicationController
- Includes:
- ActionController::Cookies
- Defined in:
- app/controllers/anoubis/application_controller.rb
Overview
Main application controller class inherited from ActionController::API
Direct Known Subclasses
Instance Attribute Summary collapse
-
#exports ⇒ Anubis::Export
Export data class.
-
#locale ⇒ Object
Current used locale.
-
#output ⇒ Anoubis::Output
Standard output.
-
#redis ⇒ Class
Returns Redis database class.
-
#redis_prefix ⇒ String
Returns Redis prefix for storing cache data.
Instance Method Summary collapse
-
#after_anoubis_initialization ⇒ Object
Procedure fires after initializes all parameters.
-
#check_origin ⇒ Boolean
Check current origin of header.
-
#default_locale ⇒ String
Returns default locale initialized in application configuration file.
-
#options(methods = 'POST') ⇒ Object
Generates options headers for CORS requests.
-
#pba_anoubis_application ⇒ Object
Procedure fires before any action and setup default variables.
Instance Attribute Details
#exports ⇒ Anubis::Export
Returns Export data class.
19 20 21 |
# File 'app/controllers/anoubis/application_controller.rb', line 19 def exports @exports end |
#locale ⇒ Object
Current used locale
11 12 13 |
# File 'app/controllers/anoubis/application_controller.rb', line 11 def locale @locale end |
#output ⇒ Anoubis::Output
Returns standard output.
15 16 17 |
# File 'app/controllers/anoubis/application_controller.rb', line 15 def output @output end |
#redis ⇒ Class
Returns Redis database class
8 9 10 |
# File 'app/controllers/anoubis/application_controller.rb', line 8 def redis @redis end |
#redis_prefix ⇒ String
Returns Redis prefix for storing cache data. Prefix can be set in Rails.configuration.anoubis_redis_prefix configuration parameter.
29 30 31 |
# File 'app/controllers/anoubis/application_controller.rb', line 29 def redis_prefix @redis_prefix end |
Instance Method Details
#after_anoubis_initialization ⇒ Object
Procedure fires after initializes all parameters
73 74 75 |
# File 'app/controllers/anoubis/application_controller.rb', line 73 def after_anoubis_initialization end |
#check_origin ⇒ Boolean
Check current origin of header. By default origin always valid
96 97 98 |
# File 'app/controllers/anoubis/application_controller.rb', line 96 def check_origin true end |
#default_locale ⇒ String
Returns default locale initialized in application configuration file. Variable is taken from Rails.configuration.i18n.default_locale parameter
24 25 26 |
# File 'app/controllers/anoubis/application_controller.rb', line 24 def default_locale Rails.configuration.i18n.default_locale.to_s end |
#options(methods = 'POST') ⇒ Object
Generates options headers for CORS requests
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/anoubis/application_controller.rb', line 80 def (methods = 'POST') return unless check_origin return unless request.origin headers['Access-Control-Allow-Origin'] = request.headers['origin'] headers['Access-Control-Allow-Methods'] = methods return if request.method != 'OPTIONS' headers['Access-Control-Max-Age'] = '1000' headers['Access-Control-Allow-Headers'] = '*,x-requested-with,Content-Type,Authorization' end |
#pba_anoubis_application ⇒ Object
Procedure fires before any action and setup default variables.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/anoubis/application_controller.rb', line 57 def pba_anoubis_application self.locale = params[:locale] if params.has_key? :locale self.locale = default_locale unless self.locale self.locale = default_locale if self.locale == '' self.exports = nil begin I18n.locale = locale rescue I18n.locale = default_locale end after_anoubis_initialization end |