Sha256: 1eb835b2d42f7608ca0dfb43b91c8a025443d09d1ae8b8b908f61036be6886ae

Contents?: true

Size: 507 Bytes

Versions: 4

Compression:

Stored size: 507 Bytes

Contents

# frozen_string_literal: true

require "pp"

module Dry
  class Struct
    def pretty_print(pp)
      klass = self.class
      pp.group(1, "#<#{klass.name || klass.inspect}", ">") do
        pp.seplist(@attributes.keys, proc { pp.text "," }) do |column_name|
          column_value = @attributes[column_name]
          pp.breakable " "
          pp.group(1) do
            pp.text column_name.to_s
            pp.text "="
            pp.pp column_value
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-struct-1.6.0 lib/dry/struct/extensions/pretty_print.rb
dry-struct-1.5.2 lib/dry/struct/extensions/pretty_print.rb
dry-struct-1.5.1 lib/dry/struct/extensions/pretty_print.rb
dry-struct-1.5.0 lib/dry/struct/extensions/pretty_print.rb