Sha256: 73b1a8e95a13f7ef9cd572105d1ddd3037fb99a5dccbc84fedaf483ef4dd85a7

Contents?: true

Size: 908 Bytes

Versions: 4

Compression:

Stored size: 908 Bytes

Contents

module SimpleAdmin
  module TitleHelper
    def title
      page_title ? "#{page_title} | #{site_title}" : site_title
    end

    def site_title
      SimpleAdmin::site_title
    end

    def page_title
      return nil unless @interface

      options = @interface.options_for(params[:action].to_sym)
      case options[:title]
      when Proc
        instance_exec(@resource, &options[:title])
      when Symbol
        if @resource
          @resource.send(optons[:title])
        else
          options[:title].to_s
        end
      when String
        options[:title]
      else
        if @resource && @resource.new_record?
          "New #{@interface.member.titleize}"
        elsif @resource
          "#{@interface.member.titleize}#{@resource.to_param.match(/\d+/) ? ' #' : ': '}#{@resource.to_param}"
        else
          @interface.collection.titlecase
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_admin-0.7.1 app/helpers/simple_admin/title_helper.rb
simple_admin-0.6.0 app/helpers/simple_admin/title_helper.rb
simple_admin-0.5.2 app/helpers/simple_admin/title_helper.rb
simple_admin-0.5.1 app/helpers/simple_admin/title_helper.rb