procore-oss/blueprinter

uninitialized constant Blueprinter::EmptyString

nikos83 opened this issue · 4 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

flop commented

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

Thank you @flop you're right!

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

@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)

Good call! Thanks @lucasmenezesds!