Class: Sharp::Action
- Inherits:
-
Rack::Action
- Object
- Rack::Action
- Sharp::Action
- Defined in:
- lib/sharp/action.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.base_name ⇒ Object
12 13 14 |
# File 'lib/sharp/action.rb', line 12 def self.base_name @base_name ||= name.sub(/Action\Z/,'') end |
.template_name ⇒ Object
32 33 34 |
# File 'lib/sharp/action.rb', line 32 def self.template_name @template_name ||= "#{base_name.underscore}.erb" end |
.view_class ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sharp/action.rb', line 20 def self.view_class if defined? @view_class @view_class else @view_class = begin view_name.constantize rescue NameError Sharp::View end end end |
.view_name ⇒ Object
16 17 18 |
# File 'lib/sharp/action.rb', line 16 def self.view_name @view_name ||= "#{base_name}View" end |
Instance Method Details
#layout ⇒ Object
40 41 42 |
# File 'lib/sharp/action.rb', line 40 def layout "layouts/application.erb" end |
#respond ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/sharp/action.rb', line 4 def respond if layout view.render(layout, :main => self.class.template_name) else view.render(self.class.template_name) end end |
#template ⇒ Object
36 37 38 |
# File 'lib/sharp/action.rb', line 36 def template self.class.template_name end |
#view ⇒ Object
44 45 46 |
# File 'lib/sharp/action.rb', line 44 def view @view ||= self.class.view_class.new end |