Class: OmniService::Inspect

Inherits:
Module
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/omni_service/inspect.rb

Overview

Module factory for custom pretty_print output. Generates a module that defines pretty_print showing specified attributes.

Examples:

Adding inspection to a class

class MyComponent
  include OmniService::Inspect.new(:name, :options)
  # Now `pp my_component` shows: #<MyComponent name=..., options=...>
end

Instance Method Summary collapse

Constructor Details

#initialize(*attributes, **kwargs) ⇒ Inspect

Returns a new instance of Inspect.



18
19
20
21
22
# File 'lib/omni_service/inspect.rb', line 18

def initialize(*attributes, **kwargs)
  super(attributes.flatten(1), kwargs)

  define_pretty_print(@attributes, @value_methods)
end