Sha256: 0d6c9ff1462be5d4f175933bb709f3b3c9b1d932c8817fefcfe3b434ef20c325

Contents?: true

Size: 846 Bytes

Versions: 6

Compression:

Stored size: 846 Bytes

Contents

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

    def site_title
      SimpleAdmin::site_title
    end

    def page_title
      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

6 entries across 6 versions & 1 rubygems

Version Path
simple_admin-0.5.0 app/helpers/simple_admin/title_helper.rb
simple_admin-0.4.1 app/helpers/simple_admin/title_helper.rb
simple_admin-0.4.0 app/helpers/simple_admin/title_helper.rb
simple_admin-0.3.1 app/helpers/simple_admin/title_helper.rb
simple_admin-0.3.0 app/helpers/simple_admin/title_helper.rb
simple_admin-0.2.1 app/helpers/simple_admin/title_helper.rb