Sha256: c46c093478a5da685d58690ed1a424a1dce756a8c6b1c98461ad2f455affbcda

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

module SiteHealth
  class Issues
    include Enumerable

    attr_reader :id

    def initialize(id)
      @id = id
      @issues = []
    end

    # Adds an issue
    # @param [Issue] issue if nil then a keywords are expected
    # @return [Array<Issue>] the current list of issues
    # @see Issue#initialize for supported keyword arguments
    def add(issue = nil, **args)
      unless issue
        args[:name] ||= id
        issue = Issue.new(args)
      end

      @issues << issue
    end
    alias_method :<<, :add

    # @return [TrueClass, FalseClass] true if there are no issues
    def empty?
      @issues.empty?
    end

    # Enumerates over every issue.
    #
    # @yieldparam [Issue] issue
    #
    # @return [Enumerator]
    #   If no block is given, an enumerator object will be returned.
    def each(&block)
      @issues.each(&block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
site_health-0.2.0 lib/site_health/issues.rb