Sha256: bf9c106a73249c3dd44b570e948b5f9daf3b87b7e4aeafa85f05910da17be866

Contents?: true

Size: 869 Bytes

Versions: 4

Compression:

Stored size: 869 Bytes

Contents

#:nodoc:
module Settings
  #:nodoc:
  module Plugin
    ##
    # Base class used for setting groups.
    #
    # @author Yorick Peterse
    # @since  0.2.5
    #
    class GroupBase
      include ::Zen::Validation

      # The name of the group
      attr_accessor :name

      # The title of the group, displayed in the GUI
      attr_accessor :title

      ##
      # Validates all attributes of this class.
      #
      # @author Yorick Peterse
      # @since  0.2.5
      #
      def validate
        validates_presence([:name, :title])
        validates_format(:name, /[a-z0-9_\-]+/)

        if ::Settings::Plugin::Settings::Registered[:groups].key?(name)
          raise(
            ::Zen::ValidationError,
            "The setting group #{name} has already been registered."
          )
        end
      end
    end # GroupBase
  end # Plugin
end # Settings

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.2.8 lib/zen/package/settings/lib/settings/plugin/group_base.rb
zen-0.2.7 lib/zen/package/settings/lib/settings/plugin/group_base.rb
zen-0.2.6.1 lib/zen/package/settings/lib/settings/plugin/group_base.rb
zen-0.2.6 lib/zen/package/settings/lib/settings/plugin/group_base.rb