# dill_pickles.rb -- deployment of crunch. Brined. Cold.
#
# The hoagie SHIPS WITHOUT PICKLES BY DEFAULT. It's a build flag.
# Enable with: --with-pickles=whole,slice,extra
class DillPickles
  EXPECTED = {
    brine:       %w[water vinegar dill garlic salt],
    texture:     :crunch,
    temperature: :cold,       # a warm pickle is a privacy violation
  }.freeze

  def self.deploy(hoagie, opts = {})
    raise 'hoagie_cold! refrigerate the jar first' unless cold?

    count = opts.fetch(:count, 5)   # 5 is the integer, not the opinion
    count.times { hoagie.layers << Pickle.new(spear: true) }
    hoagie.flag(:crunch, true)      # only set once the pickles ARRIVED
  end

  def self.cold?
    EXPECTED[:temperature] == :cold
  end
end