Sha256: 9cc637a46f9703fd3a9eb4e8edf92823c9bb6c5a20837761c2905e0f2676e7f2

Contents?: true

Size: 891 Bytes

Versions: 12

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true

require 'rails_admin/config/fields/group'

module RailsAdmin
  module Config
    module HasGroups
      # Accessor for a group
      #
      # If group with given name does not yet exist it will be created. If a
      # block is passed it will be evaluated in the context of the group
      def group(name, &block)
        group = parent.groups.detect { |g| name == g.name }
        group ||= (parent.groups << RailsAdmin::Config::Fields::Group.new(self, name)).last
        group.tap { |g| g.section = self }.instance_eval(&block) if block
        group
      end

      # Reader for groups that are marked as visible
      def visible_groups
        parent.groups.collect { |f| f.section = self; f.with(bindings) }.select(&:visible?).select do |g| # rubocop:disable Style/Semicolon
          g.visible_fields.present?
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rails_admin-3.2.1 lib/rails_admin/config/has_groups.rb
rails_admin-3.2.0 lib/rails_admin/config/has_groups.rb
rails_admin-3.2.0.rc lib/rails_admin/config/has_groups.rb
rails_admin-3.2.0.beta lib/rails_admin/config/has_groups.rb
rails_admin-3.1.4 lib/rails_admin/config/has_groups.rb
rails_admin-3.1.3 lib/rails_admin/config/has_groups.rb
rails_admin-3.1.2 lib/rails_admin/config/has_groups.rb
rails_admin-3.1.1 lib/rails_admin/config/has_groups.rb
rails_admin-3.1.0 lib/rails_admin/config/has_groups.rb
rails_admin-3.1.0.rc2 lib/rails_admin/config/has_groups.rb
rails_admin-3.1.0.rc lib/rails_admin/config/has_groups.rb
rails_admin-3.1.0.beta lib/rails_admin/config/has_groups.rb