Class: Dry::Monads::Extensions::PrettyPrint::PrintValue Private
- Inherits:
-
Module
- Object
- Module
- Dry::Monads::Extensions::PrettyPrint::PrintValue
- Defined in:
- lib/dry/monads/extensions/pretty_print.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(constructor, accessor: :value!) ⇒ PrintValue
constructor
private
A new instance of PrintValue.
Constructor Details
#initialize(constructor, accessor: :value!) ⇒ PrintValue
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of PrintValue.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dry/monads/extensions/pretty_print.rb', line 8 def initialize(constructor, accessor: :value!) super() define_method(:pretty_print) do |pp| value = public_send(accessor) pp.text "#{constructor}(" unless Unit.equal?(value) pp.group(1) do pp.breakable("") pp.pp(value) end end pp.text ")" end end |