Module: Gon::EnvFinder
- Defined in:
- lib/gon/env_finder.rb
Constant Summary collapse
- ENV_CONTROLLER_KEY =
'action_controller.instance'
- ENV_RESPONSE_KEY =
'action_controller.rescue.response'
Class Method Summary collapse
Class Method Details
.controller_env(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gon/env_finder.rb', line 8 def controller_env( = {}) [:controller] || ( current_gon && current_gon.env[ENV_CONTROLLER_KEY] || current_gon.env[ENV_RESPONSE_KEY]. instance_variable_get('@template'). instance_variable_get('@controller') ) end |
.template_path(options, extension) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gon/env_finder.rb', line 19 def template_path(, extension) if [:template] if right_extension?(extension, [:template]) [:template] else [[:template], extension].join('.') end else controller = controller_env().controller_path action = controller_env().action_name "app/views/#{controller}/#{action}.json.#{extension}" end end |