Sha256: 8c59bb7fb273ffe59c33646b9151e0bba97a869333c6c518629235671e8c33c9

Contents?: true

Size: 735 Bytes

Versions: 9

Compression:

Stored size: 735 Bytes

Contents

module AbAdmin
  module Menu
    class BaseGroup
      include ::Rails.application.routes.url_helpers
      include ::AbAdmin::Utils::EvalHelpers

      def link(title, path, options={})
        @menu_tree << Item.new(title, path, options)
      end

      def model(model, options={})
        title = options[:title] || model.model_name.human(count: 9)
        url = options[:url] || "/admin/#{model.model_name.plural}"
        @menu_tree << Item.new(title, url, options)
      end

      def group(title, options={}, &block)
        @menu_tree << Group.new(title, options, &block)
      end

      def render_nested(template)
        @menu_tree.map { |item| item.render(template) }.compact.join.html_safe
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ab_admin-0.9.0 lib/ab_admin/menu/base_group.rb
ab_admin-0.8.3 lib/ab_admin/menu/base_group.rb
ab_admin-0.8.2 lib/ab_admin/menu/base_group.rb
ab_admin-0.8.1 lib/ab_admin/menu/base_group.rb
ab_admin-0.8.0 lib/ab_admin/menu/base_group.rb
ab_admin-0.7.0 lib/ab_admin/menu/base_group.rb
ab_admin-0.6.1 lib/ab_admin/menu/base_group.rb
ab_admin-0.6.0 lib/ab_admin/menu/base_group.rb
ab_admin-0.5.0 lib/ab_admin/menu/base_group.rb