Sha256: 9e02700b6c46ad94ce36df2051dbcdbee397fa4745613e9885934d81e7104760

Contents?: true

Size: 743 Bytes

Versions: 2

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

require 'sunrise/config/group'

module Sunrise
  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, options = nil, &block)
        groups[name] ||= Sunrise::Config::Group.new(abstract_model, self, name, options)
        groups[name].instance_eval &block if block
        groups[name]
      end

      # Reader for groups
      def groups
        @groups ||= {}
      end

      # Reader for groups that are marked as visible
      def visible_groups
        groups.select { |g| g.visible? }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunrise-cms-1.1.1 lib/sunrise/config/has_groups.rb
sunrise-cms-1.1.0 lib/sunrise/config/has_groups.rb