module Prezzo
  module Calculator
    def initialize(context = {})
      @context = validated!(context)
    end

    def calculate
      raise "Calculate not implemented"
    end

    private

    def validated!(context)
      raise "Empty Context" if context.nil?
      raise "Invalid Context" if context.respond_to?(:valid?) && !context.valid?

      context
    end

    def context
      @context
    end
  end
end

module Prezzo
  module Calculator
    def initialize(context = {})
      @context = validated!(context)
    end

    def calculate
      raise "Calculate not implemented"
    end

    private

    attr_reader :context

    def validated!(context)
      raise "Empty Context" if context.nil?
      raise "Invalid Context" if context.respond_to?(:valid?) && !context.valid?

      context
    end
  end
end

Replace manual accessor with attr_reader
refactor: Replace manual accessor with attr_reader
