Module: Rmobio::ConfigManager
- Defined in:
- lib/rmobio/config_manager.rb
Constant Summary collapse
- EXTERNAL_CONTEXT_PROP =
'_external_context'
- MOBIO_CONFIG =
app_yaml_file[RAILS_ENV]
Instance Method Summary collapse
-
#get_external_context(url = nil) ⇒ Object
get_request_context This method checks for the existence of a “mobio-context” header.
Instance Method Details
#get_external_context(url = nil) ⇒ Object
get_request_context This method checks for the existence of a “mobio-context” header. If the header exists, then the method returns the filtered value for the MOBIO_CONFIG array with the key “url.”
Below is the flow:
A request is made to the server which contains a mobio-context header with a value of “mycustomcontext” to “/news”
Calling get_request_context(some_url_property) would return
“/mycustomcontext/news”
If no header exists, the method returns the value of the property, unfiltered
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rmobio/config_manager.rb', line 108 def get_external_context(url=nil) context = request.env['HTTP_MOBIO_CONTEXT'] if url if context and context != '' external_context = MOBIO_CONFIG[url].gsub(EXTERNAL_CONTEXT_PROP, context) RAILS_DEFAULT_LOGGER.debug 'ConfigManager: Setting the uri to: "' + external_context + '" for the current request.' unless not defined? RAILS_DEFAULT_LOGGER return external_context else return MOBIO_CONFIG[url].gsub('/' + EXTERNAL_CONTEXT_PROP, '') end end end |