Module: ArInternals
- Defined in:
- app/models/ar_internals.rb
Overview
Internals model returns some Rails environment variables like session, params, record ... with more user friendly names. These names can be used for interacting with users and hide complexity behind the scene.
eg: ArInternals.get('current_user_name') will return session
Predefined internal values are: current_user current_user_name current_site
Constant Summary collapse
- INTERNALS =
{ 'current_user' => 'session[:user_id]', 'current_user_name' => 'session[:user_name]', 'current_site' => 'agile_get_site.id' }
Class Method Summary collapse
-
.add(hash) ⇒ Object
Add additional internal.
- .get(key) ⇒ Object
Class Method Details
.add(hash) ⇒ Object
Add additional internal. This method allows application specific internals to be added to structure and be used together with predefined values.
48 49 50 |
# File 'app/models/ar_internals.rb', line 48 def self.add(hash) hash.each { |key, value| @additions[key] = value } end |
.get(key) ⇒ Object
55 56 57 58 |
# File 'app/models/ar_internals.rb', line 55 def self.get(key) key.delete_prefix!('@') INTERNALS[key] || @additions[key] end |