blueprinter icon indicating copy to clipboard operation
blueprinter copied to clipboard

uninitialized constant Blueprinter::EmptyString

Open nikos83 opened this issue 3 years ago • 2 comments

When I tried to use default_if I got this error

class RestaurantBlueprint < Blueprinter::Base
...
field :meal do |package|
    {
      price: package.price, default_if: Blueprinter::EmptyString, default: "N/A",
      original_price: package.original_price
    }
  end

I use gem 'blueprinter', '~> 0.25.3' ruby 2.7.2p137

nikos83 avatar Jul 10 '22 22:07 nikos83

The sample in the readme is false. It should be Blueprinter::EMPTY_STRING : https://github.com/procore/blueprinter/blob/v0.25.3/lib/blueprinter/empty_types.rb#L6

flop avatar Jul 19 '22 18:07 flop

Thank you @flop you're right!

  EMPTY_COLLECTION = "empty_collection".freeze
  EMPTY_HASH = "empty_hash".freeze
  EMPTY_STRING = "empty_string".freeze

nikos83 avatar Jul 19 '22 18:07 nikos83

@lessthanjacob I believe you could close this issue, the readme is already updated with the fix (PR: https://github.com/procore/blueprinter/pull/304/files)

lucasmenezesds avatar Jul 30 '23 18:07 lucasmenezesds

Good call! Thanks @lucasmenezesds!

lessthanjacob avatar Jul 31 '23 16:07 lessthanjacob