Module: Plotline::ApplicationHelper
- Defined in:
- app/helpers/plotline/application_helper.rb
Instance Method Summary collapse
- #body_class(options = {}) ⇒ Object
- #present(object, klass = nil) {|presenter| ... } ⇒ Object
- #title(title = nil) ⇒ Object
Instance Method Details
#body_class(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/plotline/application_helper.rb', line 11 def body_class( = {}) controller_name = controller.controller_path.gsub('/','-') basic_body_class = "#{controller_name} #{controller_name}-#{controller.action_name}" if content_for?(:body_class) [basic_body_class, content_for(:body_class)].join(' ') else basic_body_class end end |
#present(object, klass = nil) {|presenter| ... } ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/plotline/application_helper.rb', line 22 def present(object, klass = nil) begin klass ||= "#{object.class}Presenter".constantize rescue NameError klass = "#{object.class.superclass}Presenter".constantize end presenter = klass.new(object, self) yield presenter if block_given? presenter end |
#title(title = nil) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/plotline/application_helper.rb', line 3 def title(title = nil) if title content_for(:title) { title } else content_for(:title) end end |