Sha256: af53a5183c656bc9274f877e1b8310f88060f170e94a62654534cfecc4fc1406

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

module Plotline
  module ApplicationHelper
    def title(title = nil)
      if title
        content_for(:title) { title }
      else
        content_for(:title)
      end
    end

    def body_class(options = {})
      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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plotline-0.1.1 app/helpers/plotline/application_helper.rb
plotline-0.1.0 app/helpers/plotline/application_helper.rb