Module: Edifice::Controller
- Defined in:
- lib/edifice/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #layout_name ⇒ Object
-
#set_edifice_names(view_name, view_path, layout) ⇒ Object
this will get called once per template.
- #view_name ⇒ Object
- #view_name_normalized ⇒ Object
- #view_path ⇒ Object
- #view_path_normalized ⇒ Object
- #write_edifice_headers ⇒ Object
Class Method Details
.included(controller) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/edifice/controller.rb', line 4 def self.included(controller) controller.helper_method(:view_path, :view_path_normalized, :view_name, :view_name_normalized, :layout_name) unless (controller == ActionMailer::Base) controller.after_filter(:write_edifice_headers) end end |
Instance Method Details
#layout_name ⇒ Object
46 47 48 |
# File 'lib/edifice/controller.rb', line 46 def layout_name @layout || 'no_layout' end |
#set_edifice_names(view_name, view_path, layout) ⇒ Object
this will get called once per template. So we make sure it only writes for the first
14 15 16 17 18 19 20 21 22 |
# File 'lib/edifice/controller.rb', line 14 def set_edifice_names(view_name, view_path, layout) unless @edifice_names_set @view_name = view_name @view_path = view_path @layout = layout @edifice_names_set = true end end |
#view_name ⇒ Object
38 39 40 |
# File 'lib/edifice/controller.rb', line 38 def view_name @view_name || 'no_view' end |
#view_name_normalized ⇒ Object
42 43 44 |
# File 'lib/edifice/controller.rb', line 42 def view_name_normalized view_name.camelcase(:lower) end |
#view_path ⇒ Object
30 31 32 |
# File 'lib/edifice/controller.rb', line 30 def view_path (@view_path || 'no_controller').gsub('/', '_') end |
#view_path_normalized ⇒ Object
34 35 36 |
# File 'lib/edifice/controller.rb', line 34 def view_path_normalized view_path.camelcase(:lower) end |
#write_edifice_headers ⇒ Object
24 25 26 27 28 |
# File 'lib/edifice/controller.rb', line 24 def write_edifice_headers response.headers['x-edifice-view_path'] = view_path_normalized response.headers['x-edifice-view_name'] = view_name_normalized response.headers['x-edifice-layout'] = layout_name end |