Sha256: cfea7f531884eb2de4e71d68f5ebfd16a245e6d50a97e5a7b8b6cb6c3c03116d

Contents?: true

Size: 726 Bytes

Versions: 8

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

module ActiveRecordDoctor
  # Turn a detector class into a human-readable help text.
  class Help
    def initialize(klass)
      @klass = klass
    end

    def to_s
      <<-HELP
#{klass.underscored_name} - #{klass.description}

Configuration options:
#{config_to_s}
      HELP
    end

    private

    attr_reader :klass

    GLOBAL_COMMENT = "local and global"
    LOCAL_COMMENT = "local only"

    def config_to_s
      klass.config.map do |key, metadata|
        type =
          if metadata[:global]
            GLOBAL_COMMENT
          else
            LOCAL_COMMENT
          end

        "  - #{key} (#{type}) - #{metadata.fetch(:description)}"
      end.join("\n")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_record_doctor-1.15.0 lib/active_record_doctor/help.rb
active_record_doctor-1.14.0 lib/active_record_doctor/help.rb
active_record_doctor-1.13.0 lib/active_record_doctor/help.rb
active_record_doctor-1.12.0 lib/active_record_doctor/help.rb
active_record_doctor-1.11.0 lib/active_record_doctor/help.rb
active_record_doctor-1.10.0 lib/active_record_doctor/help.rb
active_record_doctor-1.9.0 lib/active_record_doctor/help.rb
active_record_doctor-1.9.0.rc1 lib/active_record_doctor/help.rb