Sha256: 6ea9e701917a20d1483c177135087d1bd2e9b06bb96f6feda9f8e2ca19d73b8f

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

# ObjectInspector is the base namespace for all modules/classes related to the
# object_inspector gem.
module ObjectInspector
  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end

  def self.reset_configuration
    @configuration = Configuration.new
  end

  class Configuration
    attr_reader :formatter_class,
                :inspect_method_prefix,
                :wild_card_scope,
                :out_of_scope_placeholder,
                :flags_separator,
                :info_separator

    def initialize
      @formatter_class = TemplatingFormatter
      @inspect_method_prefix = "inspect".freeze
      @wild_card_scope = "all".freeze
      @out_of_scope_placeholder = "*".freeze
      @flags_separator = " / ".freeze
      @info_separator = " | ".freeze
    end

    def formatter_class=(value)
      unless value.is_a?(Class)
        raise TypeError, "Formatter must be a Class constant"
      end

      @formatter_class = value
    end

    def inspect_method_prefix=(value)
      @inspect_method_prefix = value.to_s.freeze
    end

    def wild_card_scope=(value)
      @wild_card_scope = value.to_s.freeze
    end

    def out_of_scope_placeholder=(value)
      @out_of_scope_placeholder = value.to_s.freeze
    end

    def flags_separator=(value)
      @flags_separator = value.to_s.freeze
    end

    def info_separator=(value)
      @info_separator = value.to_s.freeze
    end
  end
end

require "object_inspector/version"
require "object_inspector/conversions"
require "object_inspector/inspector"
require "object_inspector/scope"
require "object_inspector/inspectors_helper"
require "object_inspector/object_interrogator"
require "object_inspector/formatters/base_formatter"
require "object_inspector/formatters/combining_formatter"
require "object_inspector/formatters/templating_formatter"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
object_inspector-0.3.1 lib/object_inspector.rb