Module: ObjectInspector

Defined in:
lib/object_inspector.rb,
lib/object_inspector/version.rb

Overview

:reek:IrresponsibleModule

Defined Under Namespace

Modules: Conversions, InspectBehaviors Classes: BaseFormatter, CombiningFormatter, Configuration, Inspector, InterrogateObject, Scope, TemplatingFormatter

Constant Summary collapse

VERSION =

The current ObjectInspector gem version.

"1.2.0"

Class Method Summary collapse

Class Method Details

.clear_errornil

Clear #last_error for the current thread/fiber.

Returns:

  • (nil)


57
58
59
# File 'lib/object_inspector.rb', line 57

def self.clear_error
  Thread.current[LAST_ERROR_THREAD_KEY] = nil
end

.configurationObject

Accessor for the Configuration object.



10
11
12
# File 'lib/object_inspector.rb', line 10

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

.configure {|configuration| ... } ⇒ Object

Yield Parameters:



15
16
17
18
19
# File 'lib/object_inspector.rb', line 15

def self.configure
  yield(configuration)

  configuration
end

.last_errorException?

The most recent exception passed to record_error on this thread/fiber. Cleared by clear_error (including after a successful gem inspect).

Returns:

  • (Exception, nil)


50
51
52
# File 'lib/object_inspector.rb', line 50

def self.last_error
  Thread.current[LAST_ERROR_THREAD_KEY]
end

.record_error(exception, object: nil) ⇒ Exception

Remember the given exception--which will have caused inspect to fall back to the original #inspect. Stored per-thread/fiber so concurrent use does not clobber it.

Calls ObjectInspector::Configuration#error_handler with exception, object: after recording.

Parameters:

  • exception (Exception)
  • object (Object, nil) (defaults to: nil)

    The object being inspected, when known.

Returns:

  • (Exception)


38
39
40
41
42
43
44
# File 'lib/object_inspector.rb', line 38

def self.record_error(exception, object: nil)
  Thread.current[LAST_ERROR_THREAD_KEY] = exception

  configuration.error_handler.(exception, object:)

  exception
end

.reset_configurationObject

Reset the current configuration settings memoized by configuration.



23
24
25
# File 'lib/object_inspector.rb', line 23

def self.reset_configuration
  @configuration = Configuration.new
end